You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@ -150,6 +150,29 @@ namespace MonoTests.System.Net.Http
|
||||
}
|
||||
}
|
||||
|
||||
class ThrowOnlyProxy : IWebProxy
|
||||
{
|
||||
public ICredentials Credentials {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
set {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public Uri GetProxy (Uri destination)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public bool IsBypassed (Uri host)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
const int WaitTimeout = 5000;
|
||||
|
||||
string TestHost, LocalServer;
|
||||
@ -297,6 +320,25 @@ namespace MonoTests.System.Net.Http
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Proxy_Disabled ()
|
||||
{
|
||||
var pp = WebRequest.DefaultWebProxy;
|
||||
|
||||
try {
|
||||
WebRequest.DefaultWebProxy = new ThrowOnlyProxy ();
|
||||
|
||||
var request = new HttpClientHandler {
|
||||
UseProxy = false
|
||||
};
|
||||
|
||||
var client = new HttpClient (request);
|
||||
Assert.IsTrue (client.GetAsync ("http://google.com").Wait (5000), "needs internet access");
|
||||
} finally {
|
||||
WebRequest.DefaultWebProxy = pp;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Send ()
|
||||
{
|
||||
@ -997,10 +1039,30 @@ namespace MonoTests.System.Net.Http
|
||||
[Category ("MobileNotWorking")] // Missing encoding
|
||||
public void GetString_Many ()
|
||||
{
|
||||
var client = new HttpClient ();
|
||||
var t1 = client.GetStringAsync ("http://example.org");
|
||||
var t2 = client.GetStringAsync ("http://example.org");
|
||||
Assert.IsTrue (Task.WaitAll (new [] { t1, t2 }, WaitTimeout));
|
||||
Action<HttpListenerContext> context = (HttpListenerContext l) => {
|
||||
var response = l.Response;
|
||||
response.StatusCode = 200;
|
||||
response.OutputStream.WriteByte (0x68);
|
||||
response.OutputStream.WriteByte (0x65);
|
||||
response.OutputStream.WriteByte (0x6c);
|
||||
response.OutputStream.WriteByte (0x6c);
|
||||
response.OutputStream.WriteByte (0x6f);
|
||||
};
|
||||
|
||||
var listener = CreateListener (context); // creates a default request handler
|
||||
AddListenerContext (listener, context); // add another request handler for the second request
|
||||
|
||||
try {
|
||||
var client = new HttpClient ();
|
||||
var t1 = client.GetStringAsync (LocalServer);
|
||||
var t2 = client.GetStringAsync (LocalServer);
|
||||
Assert.IsTrue (Task.WaitAll (new [] { t1, t2 }, WaitTimeout));
|
||||
Assert.AreEqual ("hello", t1.Result, "#1");
|
||||
Assert.AreEqual ("hello", t2.Result, "#2");
|
||||
} finally {
|
||||
listener.Abort ();
|
||||
listener.Close ();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -1155,6 +1217,13 @@ namespace MonoTests.System.Net.Http
|
||||
var l = new HttpListener ();
|
||||
l.Prefixes.Add (string.Format ("http://+:{0}/", port));
|
||||
l.Start ();
|
||||
AddListenerContext(l, contextAssert);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
HttpListener AddListenerContext (HttpListener l, Action<HttpListenerContext> contextAssert)
|
||||
{
|
||||
l.BeginGetContext (ar => {
|
||||
var ctx = l.EndGetContext (ar);
|
||||
|
||||
|
Reference in New Issue
Block a user