Exemplo n.º 1
0
 public NetworkHandler()
 {
     _httpSocketClient = new HttpSocketClient();
 }
Exemplo n.º 2
0
        private static async Task HttpConnectExampleAsync(int privoxyPort)
        {
            var socket = Tcp.ConnectToServer("127.0.0.1", privoxyPort);
            var httpSocketClient = new HttpSocketClient();

            var connectRequest = new HttpRequestMessage(new HttpMethod("CONNECT"), "http://icanhazip.com/");
            var connectStream = await httpSocketClient.GetStreamAsync(socket, connectRequest);
            await httpSocketClient.SendRequestAsync(connectStream, connectRequest);
            var receiveResponse = await httpSocketClient.ReceiveResponseAsync(connectStream, connectRequest);
            Console.WriteLine("{0} {1}", (int)receiveResponse.StatusCode, receiveResponse.ReasonPhrase);

            var getRequest = new HttpRequestMessage(HttpMethod.Get, "http://icanhazip.com/");
            var getStream = await httpSocketClient.GetStreamAsync(socket, getRequest);
            await httpSocketClient.SendRequestAsync(getStream, getRequest);
            var getResponse = await httpSocketClient.ReceiveResponseAsync(getStream, getRequest);
            Console.WriteLine("{0} {1}", (int)getResponse.StatusCode, getResponse.ReasonPhrase);
            Console.WriteLine((await getResponse.Content.ReadAsStringAsync()).Trim());
        }
Exemplo n.º 3
0
 public NetworkHandler()
 {
     _httpSocketClient = new HttpSocketClient();
 }