Java 类org.apache.http.RequestLine 实例源码

项目:smart_plan    文件:DatabaseDataRequestHandler.java   
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
    RequestLine line = request.getRequestLine();
    Uri uri = Uri.parse(line.getUri());
    DatabaseDataEntity entity;
    if (uri != null) {
        String database = uri.getQueryParameter("database");
        String tableName = uri.getQueryParameter("table");
        entity = getDataResponse(database, tableName);
        if (entity != null) {
            response.setStatusCode(200);
            response.setEntity(new StringEntity(ParserJson.getSafeJsonStr(entity), "utf-8"));
            return;
        }
    }
    entity = new DatabaseDataEntity();
    entity.setDataList(new ArrayList<Map<String, String>>());
    entity.setCode(BaseEntity.FAILURE_CODE);
    response.setStatusCode(200);
    response.setEntity(new StringEntity(ParserJson.getSafeJsonStr(entity), "utf-8"));
}
项目:lams    文件:RequestWrapper.java   
public RequestWrapper(final HttpRequest request) throws ProtocolException {
    super();
    if (request == null) {
        throw new IllegalArgumentException("HTTP request may not be null");
    }
    this.original = request;
    setParams(request.getParams());
    setHeaders(request.getAllHeaders());
    // Make a copy of the original URI
    if (request instanceof HttpUriRequest) {
        this.uri = ((HttpUriRequest) request).getURI();
        this.method = ((HttpUriRequest) 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;
}
项目:lams    文件:BasicLineParser.java   
public final static
    RequestLine parseRequestLine(final String value,
                                 LineParser parser)
    throws ParseException {

    if (value == null) {
        throw new IllegalArgumentException
            ("Value to parse may not be null.");
    }

    if (parser == null)
        parser = BasicLineParser.DEFAULT;

    CharArrayBuffer buffer = new CharArrayBuffer(value.length());
    buffer.append(value);
    ParserCursor cursor = new ParserCursor(0, value.length());
    return parser.parseRequestLine(buffer, cursor);
}
项目:lams    文件:BasicLineFormatter.java   
/**
 * Actually formats a request line.
 * Called from {@link #formatRequestLine}.
 *
 * @param buffer    the empty buffer into which to format,
 *                  never <code>null</code>
 * @param reqline   the request line to format, never <code>null</code>
 */
protected void doFormatRequestLine(final CharArrayBuffer buffer,
                                   final RequestLine reqline) {
    final String method = reqline.getMethod();
    final 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());
}
项目:lams    文件:DefaultHttpRequestFactory.java   
public HttpRequest newHttpRequest(final RequestLine requestline)
        throws MethodNotSupportedException {
    if (requestline == null) {
        throw new IllegalArgumentException("Request line may not be null");
    }
    String method = requestline.getMethod();
    if (isOneOf(RFC2616_COMMON_METHODS, method)) {
        return new BasicHttpRequest(requestline);
    } else if (isOneOf(RFC2616_ENTITY_ENC_METHODS, method)) {
        return new BasicHttpEntityEnclosingRequest(requestline);
    } else if (isOneOf(RFC2616_SPECIAL_METHODS, method)) {
        return new BasicHttpRequest(requestline);
    } else {
        throw new MethodNotSupportedException(method +  " method not supported");
    }
}
项目:maud    文件:Providers.java   
private void regen(final String from) {
    profile = new TabunAccessProfile() {
        {
            if (from != null)
                setUpFromString(from);
        }

        @Override
        public HttpResponse exec(HttpRequestBase request, boolean follow, int timeout) {
            final RequestLine rl = request.getRequestLine();
            Log.d("Moonlight", rl.getMethod() + " " + rl.getUri());
            return super.exec(request, follow, timeout);
        }
    };

}
项目:remote-files-sync    文件:BasicLineFormatterHC4.java   
/**
 * Actually formats a request line.
 * Called from {@link #formatRequestLine}.
 *
 * @param buffer    the empty buffer into which to format,
 *                  never <code>null</code>
 * @param reqline   the request line to format, never <code>null</code>
 */
protected void doFormatRequestLine(final CharArrayBuffer buffer,
                                   final RequestLine reqline) {
    final String method = reqline.getMethod();
    final String uri    = reqline.getUri();

    // room for "GET /index.html HTTP/1.1"
    final 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());
}
项目:wingtips    文件:WingtipsHttpClientBuilderTest.java   
@Before
public void beforeMethod() {
    resetTracing();

    spanRecorder = new SpanRecorder();
    Tracer.getInstance().addSpanLifecycleListener(spanRecorder);

    builder = new WingtipsHttpClientBuilder();

    requestMock = mock(HttpRequest.class);
    responseMock = mock(HttpResponse.class);
    httpContext = new BasicHttpContext();
    requestLineMock = mock(RequestLine.class);

    method = "GET";
    uri = "http://localhost:4242/foo/bar";

    doReturn(requestLineMock).when(requestMock).getRequestLine();
    doReturn(method).when(requestLineMock).getMethod();
    doReturn(uri).when(requestLineMock).getUri();
    doReturn(HTTP_1_1).when(requestLineMock).getProtocolVersion();
}
项目:wingtips    文件:WingtipsApacheHttpClientInterceptorTest.java   
@Before
public void beforeMethod() {
    resetTracing();

    interceptor = new WingtipsApacheHttpClientInterceptor();

    requestMock = mock(HttpRequest.class);
    responseMock = mock(HttpResponse.class);
    httpContext = new BasicHttpContext();
    requestLineMock = mock(RequestLine.class);

    method = "GET";
    uri = "http://localhost:4242/foo/bar";

    doReturn(requestLineMock).when(requestMock).getRequestLine();
    doReturn(method).when(requestLineMock).getMethod();
    doReturn(uri).when(requestLineMock).getUri();
}
项目:purecloud-iot    文件:CachingHttpClient.java   
boolean clientRequestsOurOptions(final HttpRequest request) {
    final RequestLine line = request.getRequestLine();

    if (!HeaderConstants.OPTIONS_METHOD.equals(line.getMethod())) {
        return false;
    }

    if (!"*".equals(line.getUri())) {
        return false;
    }

    if (!"0".equals(request.getFirstHeader(HeaderConstants.MAX_FORWARDS).getValue())) {
        return false;
    }

    return true;
}
项目:purecloud-iot    文件:CachingExec.java   
boolean clientRequestsOurOptions(final HttpRequest request) {
    final RequestLine line = request.getRequestLine();

    if (!HeaderConstants.OPTIONS_METHOD.equals(line.getMethod())) {
        return false;
    }

    if (!"*".equals(line.getUri())) {
        return false;
    }

    if (!"0".equals(request.getFirstHeader(HeaderConstants.MAX_FORWARDS).getValue())) {
        return false;
    }

    return true;
}
项目:purecloud-iot    文件:HttpRequestWrapper.java   
@Override
public RequestLine getRequestLine() {
    if (this.requestLine == null) {
        String requestUri;
        if (this.uri != null) {
            requestUri = this.uri.toASCIIString();
        } else {
            requestUri = this.original.getRequestLine().getUri();
        }
        if (requestUri == null || requestUri.isEmpty()) {
            requestUri = "/";
        }
        this.requestLine = new BasicRequestLine(this.method, requestUri, getProtocolVersion());
    }
    return this.requestLine;
}
项目:purecloud-iot    文件:RequestWrapper.java   
public RequestWrapper(final HttpRequest request) throws ProtocolException {
    super();
    Args.notNull(request, "HTTP request");
    this.original = request;
    setParams(request.getParams());
    setHeaders(request.getAllHeaders());
    // Make a copy of the original URI
    if (request instanceof HttpUriRequest) {
        this.uri = ((HttpUriRequest) request).getURI();
        this.method = ((HttpUriRequest) request).getMethod();
        this.version = null;
    } else {
        final RequestLine requestLine = request.getRequestLine();
        try {
            this.uri = new URI(requestLine.getUri());
        } catch (final URISyntaxException ex) {
            throw new ProtocolException("Invalid request URI: "
                    + requestLine.getUri(), ex);
        }
        this.method = requestLine.getMethod();
        this.version = request.getProtocolVersion();
    }
    this.execCount = 0;
}
项目:Visit    文件:BasicLineFormatterHC4.java   
/**
 * Actually formats a request line.
 * Called from {@link #formatRequestLine}.
 *
 * @param buffer    the empty buffer into which to format,
 *                  never <code>null</code>
 * @param reqline   the request line to format, never <code>null</code>
 */
protected void doFormatRequestLine(final CharArrayBuffer buffer,
                                   final RequestLine reqline) {
    final String method = reqline.getMethod();
    final String uri    = reqline.getUri();

    // room for "GET /index.html HTTP/1.1"
    final 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());
}
项目:soabase    文件:WrappedHttpRequest.java   
@Override
public RequestLine getRequestLine()
{
    return new RequestLine()
    {
        @Override
        public String getMethod()
        {
            return implementation.getRequestLine().getMethod();
        }

        @Override
        public ProtocolVersion getProtocolVersion()
        {
            return implementation.getRequestLine().getProtocolVersion();
        }

        @Override
        public String getUri()
        {
            return newUri.toString();
        }
    };
}
项目:cJUnit-mc626    文件:RequestWrapper.java   
public RequestWrapper(final HttpRequest request) throws ProtocolException {
    super();
    if (request == null) {
        throw new IllegalArgumentException("HTTP request may not be null");
    }
    this.original = request;
    setParams(request.getParams());
    // Make a copy of the original URI 
    if (request instanceof HttpUriRequest) {
        this.uri = ((HttpUriRequest) request).getURI();
        this.method = ((HttpUriRequest) 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;
}
项目:sana.mobile    文件:DispatchRequestFactory.java   
@Override
public HttpRequest newHttpRequest(String method, String uri)
        throws MethodNotSupportedException {
    RequestLine line = new BasicRequestLine(method, uri, HttpVersion.HTTP_1_1);

    HttpUriRequest request = null;
    if(method.equals(HttpGet.METHOD_NAME)){
        request = new HttpGet(uri);
    }else if(method.equals(HttpPost.METHOD_NAME)){
        request = new HttpPost(uri);
    }else if(method.equals(HttpPut.METHOD_NAME)){
        request = new HttpPut(uri);
    }else if(method.equals(HttpPut.METHOD_NAME)){
        request = new HttpDelete(uri);
    }
    return request;
}
项目:MAKEYOURFACE    文件:BasicLineParser.java   
public final static
    RequestLine parseRequestLine(final String value,
                                 LineParser parser)
    throws ParseException {

    if (value == null) {
        throw new IllegalArgumentException
            ("Value to parse may not be null.");
    }

    if (parser == null)
        parser = BasicLineParser.DEFAULT;

    CharArrayBuffer buffer = new CharArrayBuffer(value.length());
    buffer.append(value);
    ParserCursor cursor = new ParserCursor(0, value.length());
    return parser.parseRequestLine(buffer, cursor);
}
项目:MAKEYOURFACE    文件:BasicLineFormatter.java   
/**
 * Actually formats a request line.
 * Called from {@link #formatRequestLine}.
 *
 * @param buffer    the empty buffer into which to format,
 *                  never <code>null</code>
 * @param reqline   the request line to format, never <code>null</code>
 */
protected void doFormatRequestLine(final CharArrayBuffer buffer,
                                   final RequestLine reqline) {
    final String method = reqline.getMethod();
    final 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());
}
项目:ZTLib    文件:BasicLineFormatterHC4.java   
/**
 * Actually formats a request line.
 * Called from {@link #formatRequestLine}.
 *
 * @param buffer    the empty buffer into which to format,
 *                  never <code>null</code>
 * @param reqline   the request line to format, never <code>null</code>
 */
protected void doFormatRequestLine(final CharArrayBuffer buffer,
                                   final RequestLine reqline) {
    final String method = reqline.getMethod();
    final String uri    = reqline.getUri();

    // room for "GET /index.html HTTP/1.1"
    final 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());
}
项目:holico    文件:HttpTranslatorTest.java   
@Test
public final void getCoapRequestLocalResourceTest() throws TranslationException {
    String resourceName = "localResource";
    String resourceString = "/" + resourceName;

    for (String httpMethod : COAP_METHODS) {
        // create the http request
        RequestLine requestLine = new BasicRequestLine(httpMethod, resourceString, HttpVersion.HTTP_1_1);
        HttpRequest httpRequest = new BasicHttpRequest(requestLine);

        // translate the request
        Request coapRequest = HttpTranslator.getCoapRequest(httpRequest, PROXY_RESOURCE, true);
        assertNotNull(coapRequest);

        // check the method translation
        int coapMethod = Integer.parseInt(HttpTranslator.HTTP_TRANSLATION_PROPERTIES.getProperty("http.request.method." + httpMethod));
        assertTrue(coapRequest.getCode() == coapMethod);

        // check the uri-path
        String uriPath = coapRequest.getFirstOption(OptionNumberRegistry.URI_PATH).getStringValue();
        assertEquals(uriPath, resourceName);

        // check the absence of the proxy-uri option
        assertNull(coapRequest.getFirstOption(OptionNumberRegistry.PROXY_URI));
    }
}
项目:mobipayments    文件:OAuthScheme.java   
public Header authenticate(Credentials credentials, HttpRequest request)
        throws AuthenticationException {
    String uri;
    String method;
    HttpUriRequest uriRequest = getHttpUriRequest(request);
    if (uriRequest != null) {
        uri = uriRequest.getURI().toString();
        method = uriRequest.getMethod();
    } else {
        // Some requests don't include the server name in the URL.
        RequestLine requestLine = request.getRequestLine();
        uri = requestLine.getUri();
        method = requestLine.getMethod();
    }
    try {
        OAuthMessage message = new OAuthMessage(method, uri, null);
        OAuthAccessor accessor = getAccessor(credentials);
        message.addRequiredParameters(accessor);
        String authorization = message.getAuthorizationHeader(getRealm());
        return new BasicHeader("Authorization", authorization);
    } catch (Exception e) {
        throw new AuthenticationException(null, e);
    }
}
项目:pcap-reconst    文件:RecordedHttpRequestFactory.java   
public HttpRequest newHttpRequest(final RequestLine requestline)
        throws MethodNotSupportedException {
    if (requestline == null) {
        throw new IllegalArgumentException("Request line may not be null");
    }
    String method = requestline.getMethod();
    if (isOneOf(RFC2616_COMMON_METHODS, method)) {
        return new RecordedHttpRequest(requestline, messdata);
    } else if (isOneOf(RFC2616_ENTITY_ENC_METHODS, method)) {
        return new RecordedHttpEntityEnclosingRequest(requestline, messdata);
    } else if (isOneOf(RFC2616_SPECIAL_METHODS, method)) {
        return new RecordedHttpRequest(requestline, messdata);
    } else {
        throw new MethodNotSupportedException(method +  " method not supported");
    }
}
项目:jmeter_oauth_plugin    文件:OAuthScheme.java   
public Header authenticate(Credentials credentials, HttpRequest request) throws AuthenticationException {
    String uri;
    String method;
    HttpUriRequest uriRequest = getHttpUriRequest(request);
    if (uriRequest != null) {
        uri = uriRequest.getURI().toString();
        method = uriRequest.getMethod();
    } else {
        // Some requests don't include the server name in the URL.
        RequestLine requestLine = request.getRequestLine();
        uri = requestLine.getUri();
        method = requestLine.getMethod();
    }
    try {
        OAuthMessage message = new OAuthMessage(method, uri, null);
        OAuthAccessor accessor = getAccessor(credentials);
        message.addRequiredParameters(accessor);
        String authorization = message.getAuthorizationHeader(getRealm());
        return new BasicHeader("Authorization", authorization);
    } catch (Exception e) {
        throw new AuthenticationException(null, e);
    }
}
项目:net.oauth    文件:OAuthScheme.java   
public Header authenticate(Credentials credentials, HttpRequest request) throws AuthenticationException {
    String uri;
    String method;
    HttpUriRequest uriRequest = getHttpUriRequest(request);
    if (uriRequest != null) {
        uri = uriRequest.getURI().toString();
        method = uriRequest.getMethod();
    } else {
        // Some requests don't include the server name in the URL.
        RequestLine requestLine = request.getRequestLine();
        uri = requestLine.getUri();
        method = requestLine.getMethod();
    }
    try {
        OAuthMessage message = new OAuthMessage(method, uri, null);
        OAuthAccessor accessor = getAccessor(credentials);
        message.addRequiredParameters(accessor);
        String authorization = message.getAuthorizationHeader(getRealm());
        return new BasicHeader("Authorization", authorization);
    } catch (Exception e) {
        throw new AuthenticationException(null, e);
    }
}
项目:net.oauth    文件:OAuthScheme.java   
public Header authenticate(Credentials credentials, HttpRequest request) throws AuthenticationException {
    String uri;
    String method;
    HttpUriRequest uriRequest = getHttpUriRequest(request);
    if (uriRequest != null) {
        uri = uriRequest.getURI().toString();
        method = uriRequest.getMethod();
    } else {
        // Some requests don't include the server name in the URL.
        RequestLine requestLine = request.getRequestLine();
        uri = requestLine.getUri();
        method = requestLine.getMethod();
    }
    try {
        OAuthMessage message = new OAuthMessage(method, uri, null);
        OAuthAccessor accessor = getAccessor(credentials);
        message.addRequiredParameters(accessor);
        String authorization = message.getAuthorizationHeader(getRealm());
        return new BasicHeader("Authorization", authorization);
    } catch (Exception e) {
        throw new AuthenticationException(null, e);
    }
}
项目:GitHub    文件:OkApacheClient.java   
private static Request transformRequest(HttpRequest request) {
  Request.Builder builder = new Request.Builder();

  RequestLine requestLine = request.getRequestLine();
  String method = requestLine.getMethod();
  builder.url(requestLine.getUri());

  String contentType = null;
  for (Header header : request.getAllHeaders()) {
    String name = header.getName();
    if ("Content-Type".equalsIgnoreCase(name)) {
      contentType = header.getValue();
    } else {
      builder.header(name, header.getValue());
    }
  }

  RequestBody body = null;
  if (request instanceof HttpEntityEnclosingRequest) {
    HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
    if (entity != null) {
      // Wrap the entity in a custom Body which takes care of the content, length, and type.
      body = new HttpEntityBody(entity, contentType);

      Header encoding = entity.getContentEncoding();
      if (encoding != null) {
        builder.header(encoding.getName(), encoding.getValue());
      }
    } else {
      body = Util.EMPTY_REQUEST;
    }
  }
  builder.method(method, body);

  return builder.build();
}
项目:GitHub    文件:OkApacheClient.java   
private static Request transformRequest(HttpRequest request) {
  Request.Builder builder = new Request.Builder();

  RequestLine requestLine = request.getRequestLine();
  String method = requestLine.getMethod();
  builder.url(requestLine.getUri());

  String contentType = null;
  for (Header header : request.getAllHeaders()) {
    String name = header.getName();
    if ("Content-Type".equalsIgnoreCase(name)) {
      contentType = header.getValue();
    } else {
      builder.header(name, header.getValue());
    }
  }

  RequestBody body = null;
  if (request instanceof HttpEntityEnclosingRequest) {
    HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
    if (entity != null) {
      // Wrap the entity in a custom Body which takes care of the content, length, and type.
      body = new HttpEntityBody(entity, contentType);

      Header encoding = entity.getContentEncoding();
      if (encoding != null) {
        builder.header(encoding.getName(), encoding.getValue());
      }
    } else {
      body = Util.EMPTY_REQUEST;
    }
  }
  builder.method(method, body);

  return builder.build();
}
项目:elasticsearch_my    文件:Response.java   
Response(RequestLine requestLine, HttpHost host, HttpResponse response) {
    Objects.requireNonNull(requestLine, "requestLine cannot be null");
    Objects.requireNonNull(host, "node cannot be null");
    Objects.requireNonNull(response, "response cannot be null");
    this.requestLine = requestLine;
    this.host = host;
    this.response = response;
}
项目:elasticsearch_my    文件:SyncResponseListenerTests.java   
private static Response mockResponse() {
    ProtocolVersion protocolVersion = new ProtocolVersion("HTTP", 1, 1);
    RequestLine requestLine = new BasicRequestLine("GET", "/", protocolVersion);
    StatusLine statusLine = new BasicStatusLine(protocolVersion, 200, "OK");
    HttpResponse httpResponse = new BasicHttpResponse(statusLine);
    return new Response(requestLine, new HttpHost("localhost", 9200), httpResponse);
}
项目:elasticsearch_my    文件:FailureTrackingResponseListenerTests.java   
private static Response mockResponse() {
    ProtocolVersion protocolVersion = new ProtocolVersion("HTTP", 1, 1);
    RequestLine requestLine = new BasicRequestLine("GET", "/", protocolVersion);
    StatusLine statusLine = new BasicStatusLine(protocolVersion, 200, "OK");
    HttpResponse httpResponse = new BasicHttpResponse(statusLine);
    return new Response(requestLine, new HttpHost("localhost", 9200), httpResponse);
}
项目:lams    文件:HttpRequestBase.java   
public RequestLine getRequestLine() {
    String method = getMethod();
    ProtocolVersion ver = getProtocolVersion();
    URI uri = getURI();
    String uritext = null;
    if (uri != null) {
        uritext = uri.toASCIIString();
    }
    if (uritext == null || uritext.length() == 0) {
        uritext = "/";
    }
    return new BasicRequestLine(method, uritext, ver);
}
项目:lams    文件:RequestWrapper.java   
public RequestLine getRequestLine() {
    String method = getMethod();
    ProtocolVersion ver = getProtocolVersion();
    String uritext = null;
    if (uri != null) {
        uritext = uri.toASCIIString();
    }
    if (uritext == null || uritext.length() == 0) {
        uritext = "/";
    }
    return new BasicRequestLine(method, uritext, ver);
}
项目:lams    文件:BasicHttpRequest.java   
/**
 * Creates an instance of this class using the given request line.
 *
 * @param requestline request line.
 */
public BasicHttpRequest(final RequestLine requestline) {
    super();
    if (requestline == null) {
        throw new IllegalArgumentException("Request line may not be null");
    }
    this.requestline = requestline;
    this.method = requestline.getMethod();
    this.uri = requestline.getUri();
}
项目:lams    文件:BasicHttpRequest.java   
/**
 * Returns the request line of this request. If an HTTP protocol version
 * was not explicitly set at the construction time, this method will obtain
 * it from the {@link HttpParams} instance associated with the object.
 *
 * @see #BasicHttpRequest(String, String)
 */
public RequestLine getRequestLine() {
    if (this.requestline == null) {
        ProtocolVersion ver = HttpProtocolParams.getVersion(getParams());
        this.requestline = new BasicRequestLine(this.method, this.uri, ver);
    }
    return this.requestline;
}
项目:lams    文件:BasicLineFormatter.java   
public CharArrayBuffer formatRequestLine(CharArrayBuffer buffer,
                                         RequestLine reqline) {
    if (reqline == null) {
        throw new IllegalArgumentException
            ("Request line may not be null");
    }

    CharArrayBuffer result = initBuffer(buffer);
    doFormatRequestLine(result, reqline);

    return result;
}
项目:lams    文件:DefaultHttpRequestParser.java   
@Override
protected HttpRequest parseHead(
        final SessionInputBuffer sessionBuffer)
    throws IOException, HttpException, ParseException {

    this.lineBuf.clear();
    int i = sessionBuffer.readLine(this.lineBuf);
    if (i == -1) {
        throw new ConnectionClosedException("Client closed connection");
    }
    ParserCursor cursor = new ParserCursor(0, this.lineBuf.length());
    RequestLine requestline = this.lineParser.parseRequestLine(this.lineBuf, cursor);
    return this.requestFactory.newHttpRequest(requestline);
}
项目:lams    文件:HttpRequestParser.java   
@Override
protected HttpMessage parseHead(
        final SessionInputBuffer sessionBuffer)
    throws IOException, HttpException, ParseException {

    this.lineBuf.clear();
    int i = sessionBuffer.readLine(this.lineBuf);
    if (i == -1) {
        throw new ConnectionClosedException("Client closed connection");
    }
    ParserCursor cursor = new ParserCursor(0, this.lineBuf.length());
    RequestLine requestline = this.lineParser.parseRequestLine(this.lineBuf, cursor);
    return this.requestFactory.newHttpRequest(requestline);
}
项目:java-logging    文件:OutboundRequestLoggingInterceptor.java   
@Override
public void process(HttpRequest request, HttpContext context) {
    RequestLine requestLine = request.getRequestLine();

    context.setAttribute("startedOn", clock.millis());
    context.setAttribute("method", requestLine.getMethod());
    context.setAttribute("url", context.getAttribute(HTTP_TARGET_HOST) + requestLine.getUri());

    LOG.info(appendEntries(requestMarkers(context)), "Outbound request start");
}
项目:PriorityOkHttp    文件:OkApacheClient.java   
private static Request transformRequest(HttpRequest request) {
  Request.Builder builder = new Request.Builder();

  RequestLine requestLine = request.getRequestLine();
  String method = requestLine.getMethod();
  builder.url(requestLine.getUri());

  String contentType = null;
  for (Header header : request.getAllHeaders()) {
    String name = header.getName();
    if ("Content-Type".equalsIgnoreCase(name)) {
      contentType = header.getValue();
    } else {
      builder.header(name, header.getValue());
    }
  }

  RequestBody body = null;
  if (request instanceof HttpEntityEnclosingRequest) {
    HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
    if (entity != null) {
      // Wrap the entity in a custom Body which takes care of the content, length, and type.
      body = new HttpEntityBody(entity, contentType);

      Header encoding = entity.getContentEncoding();
      if (encoding != null) {
        builder.header(encoding.getName(), encoding.getValue());
      }
    } else {
      body = RequestBody.create(null, new byte[0]);
    }
  }
  builder.method(method, body);

  return builder.build();
}