From 87374274b9a53003de40828f7eb2906ecd9ed8ed Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 1 Jan 2012 23:44:46 -0500 Subject: Fix for failed http request status Thanks "sendapatch" for fixes to llHTTPRequest status reporting. --- .../Scripting/HttpRequest/ScriptsHttpRequests.cs | 31 ++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 43672d1..8fb5d75 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -411,8 +411,21 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest } Request.Timeout = HttpTimeout; - // execute the request - response = (HttpWebResponse) Request.GetResponse(); + try + { + // execute the request + 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(); @@ -436,17 +449,8 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest } 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; - ResponseBody = e.Message; - } + Status = (int)OSHttpStatusCode.ClientErrorJoker; + ResponseBody = e.Message; _finished = true; return; @@ -457,7 +461,6 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest response.Close(); } - Status = (int)OSHttpStatusCode.SuccessOk; _finished = true; } -- cgit v1.1