Exemple #1
0
    internal static HttpRequest CreateConnectRequest (Uri uri)
    {
      var host = uri.DnsSafeHost;
      var port = uri.Port;
      var authority = String.Format ("{0}:{1}", host, port);
      var req = new HttpRequest ("CONNECT", authority);
      req.Headers["Host"] = port == 80 ? host : authority;

      return req;
    }
Exemple #2
0
    internal static HttpRequest CreateWebSocketRequest (Uri uri)
    {
      var req = new HttpRequest ("GET", uri.PathAndQuery);

      var headers = req.Headers;
      headers["Upgrade"] = "websocket";
      headers["Connection"] = "Upgrade";
      headers["Host"] = uri.Port == 80 ? uri.DnsSafeHost : uri.Authority;

      return req;
    }
Exemple #3
0
    // As client
    private HttpResponse sendHttpRequest (HttpRequest request, int millisecondsTimeout)
    {
      _logger.Debug ("A request to the server:\n" + request.ToString ());
      var res = request.GetResponse (_stream, millisecondsTimeout);
      _logger.Debug ("A response to this request:\n" + res.ToString ());

      return res;
    }