Пример #1
0
        private static async Task MakeChunkedRequest()
        {
            var client = new OwinHttpClient();
            var env = RequestBuilder.Get("http://www.google.com/");
            await client.Invoke(env);

            await PrintResponse(env);
        }
Пример #2
0
        private static async Task MakeNancyRequest()
        {
            var client = new OwinHttpClient(app =>
            {
                app.UseNancy();
            });

            var nancyEnv = RequestBuilder.Get("http://foo/hello");

            await client.Invoke(nancyEnv);

            await PrintResponse(nancyEnv);
        }
Пример #3
0
        private static async Task MakeWebApiRequest() 
        {
            var client = new OwinHttpClient(app => 
            {
                var config = new HttpConfiguration();
                config.Routes.MapHttpRoute("DefaultRoute", "{controller}");
                app.UseHttpServer(config);
            });

            var webApiEnv = RequestBuilder.Get("http://foo/cars");
            await client.Invoke(webApiEnv);
            await PrintResponse(webApiEnv);
        }
Пример #4
0
        private static async Task MakeSignalRRequest()
        {
            var client = new OwinHttpClient(app =>
            {
                app.MapHubs();
            });

            var env = RequestBuilder.Get("http://foo/signalr/hubs");

            await client.Invoke(env);

            await PrintResponse(env);
        }
Пример #5
0
        private static async Task FollowRedirects(int n)
        {
            var client = new OwinHttpClient();

            string url = "http://httpbin.org/redirect/" + n;

            var env = RequestBuilder.Get(url);

            await client.Invoke(env);

            await PrintResponse(env);
        }
Пример #6
0
        private static async Task MakeRequest(int statusCode)
        {
            var client = new OwinHttpClient();
            var env = RequestBuilder.Get("http://httpbin.org/status/" + statusCode);
            await client.Invoke(env);

            await PrintResponse(env);
        }
Пример #7
0
        private static async Task MakeRawRequest()
        {
            string rawRequest =
@"GET http://httpbin.org/get HTTP/1.1
Host: httpbin.org
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

";

            var client = new OwinHttpClient();

            var env = RequestBuilder.FromRaw(rawRequest);

            await client.Invoke(env);

            await PrintResponse(env);
        }
Пример #8
0
        private static async Task MakeGzippedRequest()
        {
            var client = new OwinHttpClient();

            var env = RequestBuilder.Get("http://httpbin.org/gzip");
            await client.Invoke(env);

            await PrintResponse(env);
        }
Пример #9
0
        private static async Task MakeBasicAuthRequest()
        {
            var client = new OwinHttpClient();
            var env = RequestBuilder.Get("http://httpbin.org/basic-auth/john/doe");

            await client.Invoke(env);

            var response = new OwinResponse(env);
            if (response.StatusCode != 401)
            {
                return;
            }

            env = RequestBuilder.Get("http://httpbin.org/basic-auth/john/doe")
                                .WithCredentials("john", "doe");

            await client.Invoke(env);

            await PrintResponse(env);
        }