public HttpResponseMessageWrapper(HttpResponseMessage httpResponseMessage) { this.httpResponseMessage = httpResponseMessage; Content = httpResponseMessage.Content == null ? null : new HttpContentWrapper(httpResponseMessage.Content); RequestMessage = httpResponseMessage.RequestMessage == null ? null : new HttpRequestMessageWrapper(httpResponseMessage.RequestMessage); ResponseHeaders = new HttpResponseHeadersWrapper(httpResponseMessage.Headers); }
public StaticResponse(int statusCode, string reasonPhrase, string contentType, Stream body) { this.statusCode = statusCode; this.reasonPhrase = reasonPhrase; headers = new HttpResponseHeaders(); if (!string.IsNullOrEmpty((contentType))) headers.ContentType.Value = contentType; headers[Constants.Http.Headers.PoweredBy] = new[] {poweredBy}; this.body = body ?? Stream.Null; }
public virtual void FillHeaders(IHttpResponseHeaders headers) { var currentContentLength = headers.ContentLength.Value; if (currentContentLength != null) { throw new InvalidOperationException($"{HttpConst.Headers.ContentLength} header is managed by {this.GetType().Name} and was not expected to be already set."); } headers.ContentLength.Value = _bytes.Length; }
public override void FillHeaders(IHttpResponseHeaders headers) { base.FillHeaders(headers); var contentType = headers.ContentType; if (contentType.RawValue != null) { throw new InvalidOperationException($"Using the {this.GetType().Name} will automatically position the {HttpConst.Headers.ContentType} header which is actually already positioned."); } contentType.MediaType = _mediaType; contentType.Charset = _charset; }
public static HttpResponseHeaders ToImplementation([CanBeNull] this IHttpResponseHeaders abstraction) { return(((IAbstraction <HttpResponseHeaders>)abstraction)?.UnsafeConvert()); }
public OwinResponse(IDictionary<string, object> data) { this.data = data; responseHeaders = new HttpResponseHeaders(data.Get<IDictionary<string, string[]>>(Constants.Owin.Response.Headers)); }
public void FillHeaders(IHttpResponseHeaders headers) { headers.ContentLength.Value = 0; }
public void Set(IHttpResponseHeaders headers) { headers.Date.Value = DateTime.UtcNow; headers.Server = "ElMariachi"; }