/// <exception cref="Apache.Http.ProtocolException"></exception> public RequestWrapper(IHttpRequest request) : base() { Args.NotNull(request, "HTTP request"); this.original = request; SetParams(request.GetParams()); SetHeaders(request.GetAllHeaders()); // Make a copy of the original URI if (request is IHttpUriRequest) { this.uri = ((IHttpUriRequest)request).GetURI(); this.method = ((IHttpUriRequest)request).GetMethod(); this.version = null; } else { RequestLine requestLine = request.GetRequestLine(); try { this.uri = new URI(requestLine.GetUri()); } catch (URISyntaxException ex) { throw new ProtocolException("Invalid request URI: " + requestLine.GetUri(), ex); } this.method = requestLine.GetMethod(); this.version = request.GetProtocolVersion(); } this.execCount = 0; }
/// <summary>Actually formats a request line.</summary> /// <remarks> /// Actually formats a request line. /// Called from /// <see cref="FormatRequestLine(Org.Apache.Http.RequestLine, LineFormatter)">FormatRequestLine(Org.Apache.Http.RequestLine, LineFormatter) /// </see> /// . /// </remarks> /// <param name="buffer"> /// the empty buffer into which to format, /// never <code>null</code> /// </param> /// <param name="reqline">the request line to format, never <code>null</code></param> protected internal virtual void DoFormatRequestLine(CharArrayBuffer buffer, RequestLine reqline) { string method = reqline.GetMethod(); string uri = reqline.GetUri(); // room for "GET /index.html HTTP/1.1" int len = method.Length + 1 + uri.Length + 1 + EstimateProtocolVersionLen(reqline .GetProtocolVersion()); buffer.EnsureCapacity(len); buffer.Append(method); buffer.Append(' '); buffer.Append(uri); buffer.Append(' '); AppendProtocolVersion(buffer, reqline.GetProtocolVersion()); }
/// <summary>Creates an instance of this class using the given request line.</summary> /// <remarks>Creates an instance of this class using the given request line.</remarks> /// <param name="requestline">request line.</param> public BasicHttpRequest(RequestLine requestline) : base() { this.requestline = Args.NotNull(requestline, "Request line"); this.method = requestline.GetMethod(); this.uri = requestline.GetUri(); }