Fix for failed http request status

Thanks "sendapatch" for fixes to llHTTPRequest status reporting.
iar_mods
BlueWall 2012-01-01 23:44:46 -05:00
parent 56dbcae402
commit 87374274b9
1 changed files with 17 additions and 14 deletions

View File

@ -411,8 +411,21 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
} }
Request.Timeout = HttpTimeout; Request.Timeout = HttpTimeout;
try
{
// execute the request // execute the request
response = (HttpWebResponse) Request.GetResponse(); response = (HttpWebResponse) Request.GetResponse();
}
catch (WebException e)
{
if (e.Status != WebExceptionStatus.ProtocolError)
{
throw;
}
response = (HttpWebResponse)e.Response;
}
Status = (int)response.StatusCode;
Stream resStream = response.GetResponseStream(); Stream resStream = response.GetResponseStream();
@ -435,18 +448,9 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
ResponseBody = sb.ToString(); ResponseBody = sb.ToString();
} }
catch (Exception e) catch (Exception e)
{
if (e is WebException && ((WebException)e).Status == WebExceptionStatus.ProtocolError)
{
HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response;
Status = (int)webRsp.StatusCode;
ResponseBody = webRsp.StatusDescription;
}
else
{ {
Status = (int)OSHttpStatusCode.ClientErrorJoker; Status = (int)OSHttpStatusCode.ClientErrorJoker;
ResponseBody = e.Message; ResponseBody = e.Message;
}
_finished = true; _finished = true;
return; return;
@ -457,7 +461,6 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
response.Close(); response.Close();
} }
Status = (int)OSHttpStatusCode.SuccessOk;
_finished = true; _finished = true;
} }