29 using System.Collections.Generic;
 
   32 using System.Reflection;
 
   33 using System.Runtime.Serialization;
 
   35 using System.Threading;
 
   37 using NUnit.Framework;
 
   39 using OpenMetaverse.Assets;
 
   40 using OpenSim.Framework;
 
   41 using OpenSim.Region.CoreModules.Scripting.HttpRequest;
 
   42 using OpenSim.Region.Framework.Scenes;
 
   43 using OpenSim.Tests.Common;
 
   63         public override string ContentType { 
get; set; }
 
   64         public override string Method { 
get; set; }
 
   66         public Func<IAsyncResult, WebResponse> OnEndGetResponse { 
get; set; }
 
   91             return OnEndGetResponse(asyncResult);
 
   97         public string Response { 
get; set; }
 
   99 #pragma warning disable 0618 
  101             : base(serializationInfo, streamingContext) {}
 
  102 #pragma warning restore 0618 
  106             return new MemoryStream(Encoding.UTF8.GetBytes(Response));
 
  112         WaitHandle m_wh = 
new ManualResetEvent(
true);
 
  114         object IAsyncResult.AsyncState 
 
  117                 throw new System.NotImplementedException ();
 
  121         WaitHandle IAsyncResult.AsyncWaitHandle 
 
  126         bool IAsyncResult.CompletedSynchronously 
 
  128             get { 
return false; }
 
  131         bool IAsyncResult.IsCompleted 
 
  154             TestHelpers.InMethod();
 
  155             TestHelpers.EnableLogging();
 
  157             if (!Util.IsPlatformMono)
 
  158                 Assert.Ignore(
"Ignoring test since can only currently run on Mono");           
 
  160             string rawResponse = 
"boom";
 
  166             twr.OnEndGetResponse += ar => 
 
  168                 SerializationInfo si = 
new SerializationInfo(typeof(HttpWebResponse), 
new FormatterConverter());
 
  169                 StreamingContext sc = 
new StreamingContext();
 
  172                 si.AddValue(
"uri", 
new Uri(
"test://arrg"));
 
  174                 si.AddValue(
"version", HttpVersion.Version11);
 
  175                 si.AddValue(
"statusCode", HttpStatusCode.NotFound);
 
  176                 si.AddValue(
"contentLength", 0);
 
  177                 si.AddValue(
"method", 
"GET");
 
  178                 si.AddValue(
"statusDescription", 
"Not Found");
 
  179                 si.AddValue(
"contentType", null);
 
  180                 si.AddValue(
"cookieCollection", 
new CookieCollection());
 
  183                 thwr.Response = rawResponse;
 
  185                 throw new WebException(
"no message", null, WebExceptionStatus.ProtocolError, thwr);
 
  188             twrc.NextRequest = twr;
 
  190             WebRequest.RegisterPrefix(
"test", twrc);
 
  192             hr.Url = 
"test://something";
 
  195             Assert.That(hr.Status, Is.EqualTo((int)HttpStatusCode.NotFound));
 
  196             Assert.That(hr.ResponseBody, Is.EqualTo(rawResponse));
 
WebRequest Create(Uri uri)
 
override IAsyncResult BeginGetResponse(AsyncCallback callback, object state)
 
Test script http request code. 
 
TestHttpWebResponse(SerializationInfo serializationInfo, StreamingContext streamingContext)
 
void Test404Response()
Test what happens when we get a 404 response from a call. 
 
override WebResponse EndGetResponse(IAsyncResult asyncResult)
 
Interactive OpenSim region server 
 
override Stream GetResponseStream()