Beispiel #1
0
 public SystemApi(IHttpAddress baseAddress, IHttpFacade httpFacade, IContentSerializer contentSerializer, IHttpHeaders baseHeaders)
 {
     this.baseAddress = baseAddress.WithResource("system");
     this.httpFacade = httpFacade;
     this.contentSerializer = contentSerializer;
     this.baseHeaders = baseHeaders;
 }
        public static async Task WriteTo(IHttpHeaders headers, Stream stream)
        {
#if PCL && !ASYNC_PCL
            var writer = new StreamWriter(new NonDisposableStream(stream), Encoding.UTF8, 128);
#else
            var writer = new StreamWriter(stream, Encoding.UTF8, 128, true);
#endif
            try
            {
                writer.NewLine = "\r\n";

                if (headers != null)
                {
                    foreach (var header in headers)
                    {
                        await
                            writer.WriteLineAsync($"{header.Key}: {string.Join(", ", header.Value)}");
                    }
                }

                await writer.WriteLineAsync();
            }
            finally
            {
                writer.Dispose();
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultHttpResponseMessage"/> class.
        /// </summary>
        /// <param name="requestMessage">The request message for this response</param>
        /// <param name="responseMessage">The response message to wrap</param>
        /// <param name="exception">The exception that occurred during the request</param>
        public DefaultHttpResponseMessage([NotNull] IHttpRequestMessage requestMessage, [NotNull] HttpWebResponse responseMessage, [CanBeNull] WebException exception = null)
        {
            ResponseMessage = responseMessage;
            _exception = exception;
            _requestMessage = requestMessage;

            var responseHeaders = new GenericHttpHeaders();
            var contentHeaders = new GenericHttpHeaders();
            if (responseMessage.SupportsHeaders)
            {
                foreach (var headerName in responseMessage.Headers.AllKeys)
                {
                    IHttpHeaders headers;
                    if (headerName.StartsWith("Content-", StringComparison.OrdinalIgnoreCase))
                    {
                        headers = contentHeaders;
                    }
                    else
                    {
                        headers = responseHeaders;
                    }

                    headers.TryAddWithoutValidation(headerName, responseMessage.Headers[headerName]);
                }
            }

            _content = new HttpWebResponseContent(contentHeaders, responseMessage);
            _responseHttpHeaders = responseHeaders;
        }
Beispiel #4
0
 public FilesApi(IHttpAddress baseAddress, IHttpFacade httpFacade, IContentSerializer contentSerializer, IHttpHeaders baseHeaders, string serviceName)
 {
     this.baseAddress = baseAddress.WithResource(serviceName);
     this.httpFacade = httpFacade;
     this.contentSerializer = contentSerializer;
     this.baseHeaders = baseHeaders;
 }
 protected static void SetResponseHeaders(int statusCode, string reasonPhrase, IHttpHeaders headers,
                                          IOwinResponse response, params string[] except)
 {
     response.StatusCode = statusCode;
     if (!string.IsNullOrEmpty(reasonPhrase))
         response.ReasonPhrase = reasonPhrase;
     headers.CopyTo(response.Headers, except);
 }
        /// <summary>
        /// Creates a new instance of the class
        /// </summary>
        /// <param name="version">HTTP version</param>
        /// <param name="headers">HTTP headers</param>
        protected HttpHeaderEventArgs( string version, IHttpHeaders headers )
        {
            Contract.Requires( !string.IsNullOrEmpty( version ) );
            Contract.Requires( headers != null );

            Version = version;
            Headers = headers;
        }
Beispiel #7
0
 public HttpRequestV2(IHttpHeaders headers, HttpMethods method, string protocol, Uri uri, string[] requestParameters)
 {
     _headers = headers;
     _method = method;
     _protocol = protocol;
     _uri = uri;
     _requestParameters = requestParameters;
 }
 public WebClientResponseMessage(string uri, byte[] data, HttpStatusCode statusCode,
                                 IHttpHeaders headers, string protocolVersion)
 {
     this.headers = headers;
     this.uri = uri;
     this.data = data;
     this.statusCode = statusCode;
     this.protocolVersion = protocolVersion;
 }
        public static long ComputeLength(IHttpHeaders headers)
        {
            long result = 2;
            foreach (var header in headers)
            {
                result += header.Key.Length + header.Value.Sum(x => x.Length + 2) + 2;
            }

            return result;
        }
        /// <summary>
        /// Creates a new instance of the class
        /// </summary>
        /// <param name="version">HTTP version</param>
        /// <param name="headers">HTTP headers</param>
        /// <param name="statusCode">HTTP response status code</param>
        /// <param name="statusText">HTTP response status text</param>
        public HttpResponseHeaderEventArgs( string version, IHttpHeaders headers, int statusCode, string statusText )
            : base(version, headers)
        {
            Contract.Requires(statusText != null);
            Contract.Requires(statusCode > 99);
            Contract.Requires(statusCode<1000);

            StatusCode = statusCode;
            StatusText = statusText;
        }
 public HttpWebResponseContent(IHttpHeaders headers, HttpWebResponse response)
 {
     Headers = headers;
     _response = response;
     IEnumerable<string> contentLength;
     if (headers.TryGetValues("content-length", out contentLength))
     {
         var headerValue = contentLength.FirstOrDefault();
         if (headerValue != null)
             _contentLength = long.Parse(headerValue);
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="HttpRequest"/> class.
        /// </summary>
        /// <param name="method">HTTP method.</param>
        /// <param name="url">URL.</param>
        /// <param name="headers">Headers collection.</param>
        public HttpRequest(HttpMethod method, string url, IHttpHeaders headers)
        {
            HttpUtils.CheckUrlString(url);

            if (headers == null)
            {
                throw new ArgumentNullException("headers");
            }

            Method = method;
            Url = url;
            Headers = headers.Exclude(HttpHeaders.ContentTypeHeader);
        }
 private static async Task<byte[]> GetPostData(HttpStreamReader streamReader, IHttpHeaders headers)
 {
     int postContentLength;
     byte[] post;
     if (headers.TryGetByName("content-length", out postContentLength))
     {
         byte[] buffer = new byte[postContentLength];
         var readBytes = await streamReader.BaseStream.ReadAsync(buffer, 0, postContentLength);
         post = buffer;
     }
     else
     {
         post = null;
     }
     return post;
 }
        public CompressedResponse(IHttpResponse child, MemoryStream memoryStream, string encoding)
        {
            _memoryStream = memoryStream;

            _responseCode = child.ResponseCode;
            _closeConnection = child.CloseConnection;
            _headers =
                new ListHttpHeaders(
                    child.Headers.Where(h => !h.Key.Equals("content-length", StringComparison.InvariantCultureIgnoreCase))
                        .Concat(new[]
                        {
                            new KeyValuePair<string, string>("content-length", memoryStream.Length.ToString(CultureInfo.InvariantCulture)),
                            new KeyValuePair<string, string>("content-encoding", encoding), 
                        })
                        .ToList());


        }
        /// <summary>
        /// Initializes a new instance of the <see cref="HttpRequest"/> class.
        /// </summary>
        /// <param name="method">HTTP method.</param>
        /// <param name="url">URL.</param>
        /// <param name="headers">Headers collection.</param>
        /// <param name="body">Body content.</param>
        public HttpRequest(HttpMethod method, string url, IHttpHeaders headers, string body)
        {
            HttpUtils.CheckUrlString(url);

            if (headers == null)
            {
                throw new ArgumentNullException("headers");
            }

            if (body == null)
            {
                throw new ArgumentNullException("body");
            }

            Body = body;
            Method = method;
            Url = url;
            Headers = headers;
        }
        /// <summary>
        /// Creates the default instance of the class
        /// </summary>
        /// <param name="version">HTTP version</param>
        /// <param name="headers">HTTP headers</param>
        /// <param name="method">HTTP request method</param>
        /// <param name="path">Remote host path</param>
        public HttpRequestHeaderEventArgs( string version, IHttpHeaders headers, string method, string path )
            : base(version, headers)
        {
            Contract.Requires( !string.IsNullOrEmpty( method ) );
            Contract.Requires( !string.IsNullOrEmpty( path ) );

            Path = path;
            Method = method;

            // Convert Proxy-Connection to Connection. This header causes some problems with certain sites.
            // See http://homepage.ntlworld.com./jonathan.deboynepollard/FGA/web-proxy-connection-header.html
            if ( version == "1.0" )
            {
                Headers.Remove( "Proxy-Connection" );
            }
            else
            {
                Headers.RenameKey( "Proxy-Connection", "Connection" );
            }
        }
Beispiel #17
0
 public EmptyHttpResponse(HttpResponseCode code, IHttpHeaders headers) : base(code, headers)
 {
 }
 public WebDavClientException(HttpStatusCode statusCode, string statusDescription, string responseMessage, IHttpHeaders headers)
     : base($"Response status code does not indicate success: '{(int)statusCode}' ('{statusDescription}'). Message:\r\n{responseMessage}")
 {
     StatusCode        = statusCode;
     StatusDescription = statusDescription;
     Headers           = headers;
     ResponseMessage   = responseMessage;
 }
Beispiel #19
0
 public T Get <T>(IHttpHeaders headers, string prefix)
 {
     return((T)Get(typeof(T), headers, prefix));
 }
 public FileUploader( IServerSettings settings, IHttpHeaders headers )
 {
     _settings = settings;
     _headers = headers;
 }
        public void OnReadResponseHeaderComplete( string version, IHttpHeaders headers, int statusCode, string statusMessage )
        {
            WebLog.Logger.Verbose( "ReadResponseHeaderComplete event raised" );

            EventHandler<HttpResponseHeaderEventArgs> responseEvent = ReadResponseHeaderComplete;
            //lock ( _mutex )
            {
                if ( responseEvent != null )
                {
                    responseEvent( this, new HttpResponseHeaderEventArgs( version, headers, statusCode, statusMessage ) );
                }
            }
        }
Beispiel #22
0
 public void SetUp()
 {
     _httpHeaders    = new HttpHeaders();
     _requestBuilder = new RequestBuilder(_httpMethodRepository, _httpVersionRepository, _httpHeaders);
 }
 public static CacheControl getCacheControl(IHttpHeaders headers, long requestTime)
 {
     CacheControl cc=new CacheControl();
     bool proxyRevalidate=false;
     int sMaxAge=0;
     bool publicCache=false;
     bool privateCache=false;
     bool noCache=false;
     long expires=0;
     bool hasExpires=false;
     cc.uri=headers.getUrl();
     string cacheControl=headers.getHeaderField("cache-control");
     if(cacheControl!=null){
       int index=0;
       int[] intval=new int[1];
       while(index<cacheControl.Length){
     int current=index;
     if((index=HeaderParser.parseToken(cacheControl,current,"private",true))!=current){
       privateCache=true;
     } else if((index=HeaderParser.parseToken(cacheControl,current,"no-cache",true))!=current){
       noCache=true;
       //Console.WriteLine("returning early because it saw no-cache");
       return null; // return immediately, this is not cacheable
     } else if((index=HeaderParser.parseToken(
     cacheControl,current,"no-store",false))!=current){
       cc.noStore=true;
       //Console.WriteLine("returning early because it saw no-store");
       return null; // return immediately, this is not cacheable or storable
     } else if((index=HeaderParser.parseToken(
     cacheControl,current,"public",false))!=current){
       publicCache=true;
     } else if((index=HeaderParser.parseToken(
     cacheControl,current,"no-transform",false))!=current){
       cc.noTransform=true;
     } else if((index=HeaderParser.parseToken(
     cacheControl,current,"must-revalidate",false))!=current){
       cc.mustRevalidate=true;
     } else if((index=HeaderParser.parseToken(
     cacheControl,current,"proxy-revalidate",false))!=current){
       proxyRevalidate=true;
     } else if((index=HeaderParser.parseTokenWithDelta(
     cacheControl,current,"max-age",intval))!=current){
       cc.maxAge=intval[0];
     } else if((index=HeaderParser.parseTokenWithDelta(
     cacheControl,current,"s-maxage",intval))!=current){
       sMaxAge=intval[0];
     } else {
       index=HeaderParser.skipDirective(cacheControl,current);
     }
       }
       if(!publicCache && !privateCache && !noCache){
     noCache=true;
       }
     } else {
       int code=headers.getResponseCode();
       if((code==200 || code==203 || code==300 || code==301 || code==410) &&
       headers.getHeaderField("authorization")==null){
     publicCache=true;
     privateCache=false;
       } else {
     noCache=true;
       }
     }
     if(headers.getResponseCode()==206) {
       noCache=true;
     }
     string pragma=headers.getHeaderField("pragma");
     if(pragma!=null && "no-cache".Equals(StringUtility.toLowerCaseAscii(pragma))){
       noCache=true;
       //Console.WriteLine("returning early because it saw pragma no-cache");
       return null;
     }
     long now=DateTimeUtility.getCurrentDate();
     cc.code=headers.getResponseCode();
     cc.date=now;
     cc.responseTime=now;
     cc.requestTime=requestTime;
     if(proxyRevalidate){
       // Enable must-revalidate for simplicity;
       // proxyRevalidate usually only applies to shared caches
       cc.mustRevalidate=true;
     }
     if(headers.getHeaderField("date")!=null){
       cc.date=headers.getHeaderFieldDate("date",Int64.MinValue);
       if(cc.date==Int64.MinValue) {
     noCache=true;
       }
     } else {
       noCache=true;
     }
     string expiresHeader=headers.getHeaderField("expires");
     if(expiresHeader!=null){
       expires=headers.getHeaderFieldDate("expires",Int64.MinValue);
       hasExpires=(cc.date!=Int64.MinValue);
     }
     if(headers.getHeaderField("age")!=null){
       try {
     cc.age=Int32.Parse(headers.getHeaderField("age"),NumberStyles.AllowLeadingSign,CultureInfo.InvariantCulture);
     if(cc.age<0) {
       cc.age=0;
     }
       } catch(FormatException){
     cc.age=-1;
       }
     }
     if(cc.maxAge>0 || sMaxAge>0){
       long maxAge=cc.maxAge; // max age in seconds
       if(maxAge==0) {
     maxAge=sMaxAge;
       }
       if(cc.maxAge>0 && sMaxAge>0){
     maxAge=Math.Max(cc.maxAge,sMaxAge);
       }
       cc.maxAge=maxAge*1000L; // max-age and s-maxage are in seconds
       hasExpires=false;
     } else if(hasExpires && !noCache){
       long maxAge=expires-cc.date;
       cc.maxAge=(maxAge>Int32.MaxValue) ? Int32.MaxValue : (int)maxAge;
     } else if(noCache || cc.noStore){
       cc.maxAge=0;
     } else {
       cc.maxAge=24L*3600L*1000L;
     }
     string reqmethod=headers.getRequestMethod();
     if(reqmethod==null || (
     !StringUtility.toLowerCaseAscii(reqmethod).Equals("get")))
       // caching responses other than GET responses not supported
       return null;
     cc.requestMethod=StringUtility.toLowerCaseAscii(reqmethod);
     cc.cacheability=2;
     if(noCache) {
       cc.cacheability=0;
     } else if(privateCache) {
       cc.cacheability=1;
     }
     int i=0;
     cc.headers.Add(headers.getHeaderField(null));
     while(true){
       string newValue=headers.getHeaderField(i);
       if(newValue==null) {
     break;
       }
       string key=headers.getHeaderFieldKey(i);
       i++;
       if(key==null){
     //Console.WriteLine("null key");
     continue;
       }
       key=StringUtility.toLowerCaseAscii(key);
       // to simplify matters, don't include Age header fields;
       // so-called hop-by-hop headers are also not included
       if(!"age".Equals(key) &&
       !"connection".Equals(key) &&
       !"keep-alive".Equals(key) &&
       !"proxy-authenticate".Equals(key) &&
       !"proxy-authorization".Equals(key) &&
       !"te".Equals(key) &&
       !"trailer".Equals(key) && // NOTE: NOT Trailers
       !"transfer-encoding".Equals(key) &&
       !"upgrade".Equals(key)){
     cc.headers.Add(key);
     cc.headers.Add(newValue);
       }
     }
     //Console.WriteLine(" cc: %s",cc);
     return cc;
 }
Beispiel #24
0
 public HttpRequest(IHttpHeaders headers, HttpMethods method, string protocol, Uri uri, string[] requestParameters, IHttpHeaders queryString, IHttpPost post)
 {
     Headers           = headers;
     Method            = method;
     Protocol          = protocol;
     Uri               = uri;
     RequestParameters = requestParameters;
     QueryString       = queryString;
     Post              = post;
 }
 /// <summary>
 /// Gets the HTTP header value or null
 /// </summary>
 /// <param name="headers">The headers to get the value from</param>
 /// <param name="name">The header name to get the value for</param>
 /// <returns>The first HTTP header value or null</returns>
 public static string GetValue(this IHttpHeaders headers, string name)
 {
     return(GetValue(headers, name, null));
 }
Beispiel #26
0
 public HttpRequest(IHttpHeaders headers, HttpMethods method, string protocol, Uri uri, string[] requestParameters, IHttpHeaders queryString, IHttpPost post)
 {
     _headers           = headers;
     _method            = method;
     _protocol          = protocol;
     _uri               = uri;
     _requestParameters = requestParameters;
     _queryString       = queryString;
     _post              = post;
 }
Beispiel #27
0
 protected HttpResponseBase(HttpResponseCode code, IHttpHeaders headers)
 {
     _code    = code;
     _headers = headers;
 }
 public HttpHeadersDebuggerProxy(IHttpHeaders real)
 {
     _real = real;
 }
 public HttpHeaderContent(IHttpHeaders headers)
 {
     Headers = headers;
 }
Beispiel #30
0
 public HttpRequest(IHttpHeaders headers, HttpMethods method, string protocol, Uri uri, string[] requestParameters, IHttpHeaders queryString, IHttpPost post)
 {
     _headers = headers;
     _method = method;
     _protocol = protocol;
     _uri = uri;
     _requestParameters = requestParameters;
     _queryString = queryString;
     _post = post;
 }
Beispiel #31
0
 public MultipartFormDataContent(IHttpHeaders headers)
 {
     Headers  = headers;
     Boundary = Guid.NewGuid().ToString("N");
     Headers.TryAddWithoutValidation("Content-Type", ContentType);
 }
        public void OnReadRequestHeaderComplete( string version, IHttpHeaders headers, string method, string path )
        {
            WebLog.Logger.Verbose( "ReadRequestHeaderComplete event raised" );

            EventHandler<HttpRequestHeaderEventArgs> requestEvent = ReadRequestHeaderComplete;
            //lock ( _mutex )
            {
                if ( requestEvent != null )
                {
                    requestEvent( this, new HttpRequestHeaderEventArgs( version, headers, method, path ) );
                }
            }
        }
Beispiel #33
0
 public SystemApi(IHttpAddress baseAddress, IHttpFacade httpFacade, IContentSerializer contentSerializer, IHttpHeaders baseHeaders)
 {
     this.baseAddress       = baseAddress.WithResource("system");
     this.httpFacade        = httpFacade;
     this.contentSerializer = contentSerializer;
     this.baseHeaders       = baseHeaders;
 }
Beispiel #34
0
 public T Get <T>(IHttpHeaders headers)
 {
     throw new NotSupportedException();
 }
Beispiel #35
0
 public T Get <T>(IHttpHeaders headers, string prefix)
 {
     throw new NotSupportedException();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultHttpClient"/> class.
 /// </summary>
 /// <param name="httpClientFactory">The factory used to create this <see cref="IHttpClient"/> implementation</param>
 /// <param name="defaultHttpHeaders">The default HTTP headers</param>
 public DefaultHttpClient([NotNull] WebRequestHttpClientFactory httpClientFactory, [NotNull] IHttpHeaders defaultHttpHeaders)
 {
     _httpClientFactory    = httpClientFactory;
     Timeout               = TimeSpan.FromSeconds(100);
     DefaultRequestHeaders = defaultHttpHeaders;
 }
 public string Serialize(IHttpHeaders headers)
 {
     return(SerializeHeaders(headers));
 }
 public WebDavClientException(Exception innerException, HttpStatusCode?statusCode, string statusDescription, IHttpHeaders headers)
     : base(innerException.Message, innerException)
 {
     StatusCode        = statusCode;
     StatusDescription = statusDescription;
     Headers           = headers;
 }
        /// <summary>
        /// Returns a modified HTTP request message object with HTTP header parameters
        /// </summary>
        /// <param name="httpHeaders">HTTP headers</param>
        /// <param name="request">REST request</param>
        /// <param name="parameters">The request parameters for the REST request except the content header parameters (read-only)</param>
        protected virtual void AddHttpHeaderParameters(IHttpHeaders httpHeaders, IRestRequest request, IList<Parameter> parameters)
        {
            foreach (var param in parameters.Where(x => x.Type == ParameterType.HttpHeader))
            {
                if (httpHeaders.Contains(param.Name))
                {
                    httpHeaders.Remove(param.Name);
                }

                var paramValue = param.ToRequestString();
                if (param.ValidateOnAdd)
                {
                    httpHeaders.Add(param.Name, paramValue);
                }
                else
                {
                    httpHeaders.TryAddWithoutValidation(param.Name, paramValue);
                }
            }
        }
Beispiel #40
0
 public FilesApi(IHttpAddress baseAddress, IHttpFacade httpFacade, IContentSerializer contentSerializer, IHttpHeaders baseHeaders, string serviceName)
 {
     this.baseAddress       = baseAddress.WithResource(serviceName);
     this.httpFacade        = httpFacade;
     this.contentSerializer = contentSerializer;
     this.baseHeaders       = baseHeaders;
 }
Beispiel #41
0
 public StringHttpResponse(string body, HttpResponseCode code, IHttpHeaders headers) : base(code, headers)
 {
     _body = body;
 }
Beispiel #42
0
 public StringHttpResponse(string body, HttpResponseCode code, IHttpHeaders headers) : base(code, headers)
 {
     _body = body;
 }
Beispiel #43
0
 protected HttpResponseBase(HttpResponseCode code, IHttpHeaders headers)
 {
     _code = code;
     _headers = headers;
 }
Beispiel #44
0
 public StreamHttpResponse(Stream body, HttpResponseCode code, IHttpHeaders headers) : base(code, headers)
 {
     _body = body;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpHeaderContent"/> class.
 /// </summary>
 /// <param name="headers">The encapsulated headers</param>
 public HttpHeaderContent(IHttpHeaders headers)
 {
     Headers = headers;
 }
Beispiel #46
0
        public static IHttpResponse Create(string body, HttpResponseCode code = HttpResponseCode.Ok, string contentType = "text/html; charset=utf-8", bool keepAlive = true, IHttpHeaders headers = null)
        {
            // TODO : Add Overload
            if (headers == null)
            {
                headers = EmptyHttpHeaders.Empty;
            }

            return(new StringHttpResponse(body, code, new CompositeHttpHeaders(new ListHttpHeaders(new[]
            {
                new KeyValuePair <string, string>("Date", DateTime.UtcNow.ToString("R")),
                new KeyValuePair <string, string>("content-type", contentType),
                new KeyValuePair <string, string>("connection", keepAlive ? "keep-alive" : "close"),
                new KeyValuePair <string, string>("content-length", Encoding.UTF8.GetByteCount(body).ToString(CultureInfo.InvariantCulture)),
            }), headers)));
        }
Beispiel #47
0
 internal HttpRequest(IRequestLine requestLine, IHttpHeaders httpHeaders, IMessageBody messageBody)
 {
     _requestLine = requestLine;
     _httpHeaders = httpHeaders;
     MessageBody  = messageBody;
 }
        private void SendResponseHeader(HttpStatus status, IHttpHeaders headers, Stream outputStream)
        {
            var httpHeader = HttpServer.SupportedHttpVersion + " " + status.Code + " " + status.Description + HttpConst.LineReturn + _headersSerializer.Serialize(headers) + HttpConst.LineReturn;

            outputStream.Write(Encoding.ASCII.GetBytes(httpHeader));
        }
Beispiel #49
0
        /// <summary>
        ///     Copies the elements of the <see cref="T:Stumps.IHttpHeaders"/> collection to another <see cref="T:Stumps.IHttpHeaders"/>.
        /// </summary>
        /// <param name="httpHeaders">The target <see cref="T:Stumps.IHttpHeaders"/>.</param>
        /// <exception cref="System.ArgumentNullException"><paramref name="httpHeaders"/> is <c>null</c>.</exception>
        public virtual void CopyTo(IHttpHeaders httpHeaders)
        {
            if (httpHeaders == null)
            {
                throw new ArgumentNullException("httpHeaders");
            }

            foreach (var headerName in this.HeaderNames)
            {
                httpHeaders[headerName] = this[headerName];
            }
        }
Beispiel #50
0
 static HttpResponse DisconnectProcessor(IHttpHeaders query, Account account)
 {
     return(new HttpResponse(HttpResponseCode.Ok, string.Empty, false));
 }
Beispiel #51
0
 public void SetHeaders()
 {
     headers = new HttpHeaders();
 }
Beispiel #52
0
 public EmptyHttpResponse(HttpResponseCode code, IHttpHeaders headers) : base(code, headers)
 {
     
 }
Beispiel #53
0
 public HttpMessage(IHttpHeaders headers, IHttpBody body)
 {
     Headers = headers;
     Body    = body;
 }
Beispiel #54
0
        public HttpResponse(HttpResponseCode code, string contentType, Stream contentStream, bool keepAliveConnection, IEnumerable<KeyValuePair<string, string>> headers)
        {
            ContentStream = contentStream;

            _closeConnection = !keepAliveConnection;

            _responseCode = code;
            _headers = new ListHttpHeaders(new[]
            {
                new KeyValuePair<string, string>("Date", DateTime.UtcNow.ToString("R")),
                new KeyValuePair<string, string>("Connection", _closeConnection ? "Close" : "Keep-Alive"),
                new KeyValuePair<string, string>("Content-Type", contentType),
                new KeyValuePair<string, string>("Content-Length", ContentStream.Length.ToString(CultureInfo.InvariantCulture)),
            }.Concat(headers).ToList());

        }
Beispiel #55
0
 public HttpMessage(IHttpHeaders headers)
     : this(headers, new HttpBody())
 {
 }
Beispiel #56
0
 public StreamHttpResponse(Stream body, HttpResponseCode code, IHttpHeaders headers) : base(code, headers)
 {
     _body = body;
 }
 public HttpHeadersDebuggerProxy(IHttpHeaders real)
 {
     _real = real;
 }