当前位置: 首页>>代码示例>>Java>>正文


Java RequestLine.getMethod方法代码示例

本文整理汇总了Java中org.apache.http.RequestLine.getMethod方法的典型用法代码示例。如果您正苦于以下问题:Java RequestLine.getMethod方法的具体用法?Java RequestLine.getMethod怎么用?Java RequestLine.getMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.RequestLine的用法示例。


在下文中一共展示了RequestLine.getMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RequestWrapper

import org.apache.http.RequestLine; //导入方法依赖的package包/类
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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:RequestWrapper.java

示例2: doFormatRequestLine

import org.apache.http.RequestLine; //导入方法依赖的package包/类
/**
 * 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());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:BasicLineFormatter.java

示例3: newHttpRequest

import org.apache.http.RequestLine; //导入方法依赖的package包/类
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");
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:DefaultHttpRequestFactory.java

示例4: doFormatRequestLine

import org.apache.http.RequestLine; //导入方法依赖的package包/类
/**
 * 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());
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:25,代码来源:BasicLineFormatterHC4.java

示例5: RequestWrapper

import org.apache.http.RequestLine; //导入方法依赖的package包/类
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;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:25,代码来源:RequestWrapper.java

示例6: RequestWrapper

import org.apache.http.RequestLine; //导入方法依赖的package包/类
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;
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:26,代码来源:RequestWrapper.java

示例7: authenticate

import org.apache.http.RequestLine; //导入方法依赖的package包/类
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);
	}
}
 
开发者ID:Simbacode,项目名称:mobipayments,代码行数:25,代码来源:OAuthScheme.java

示例8: newHttpRequest

import org.apache.http.RequestLine; //导入方法依赖的package包/类
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");
    }
}
 
开发者ID:cjneasbi,项目名称:pcap-reconst,代码行数:17,代码来源:RecordedHttpRequestFactory.java

示例9: authenticate

import org.apache.http.RequestLine; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:groovenauts,项目名称:jmeter_oauth_plugin,代码行数:24,代码来源:OAuthScheme.java

示例10: transformRequest

import org.apache.http.RequestLine; //导入方法依赖的package包/类
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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:37,代码来源:OkApacheClient.java

示例11: BasicHttpRequest

import org.apache.http.RequestLine; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:BasicHttpRequest.java

示例12: transformRequest

import org.apache.http.RequestLine; //导入方法依赖的package包/类
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();
}
 
开发者ID:lizhangqu,项目名称:PriorityOkHttp,代码行数:37,代码来源:OkApacheClient.java

示例13: newHttpRequest

import org.apache.http.RequestLine; //导入方法依赖的package包/类
public HttpRequest newHttpRequest(final RequestLine requestline)
        throws MethodNotSupportedException {
    Args.notNull(requestline, "Request line");
    final 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");
    }
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:15,代码来源:DefaultHttpRequestFactoryHC4.java

示例14: newHttpRequest

import org.apache.http.RequestLine; //导入方法依赖的package包/类
public HttpRequest newHttpRequest(final RequestLine requestline)
        throws MethodNotSupportedException {
    if (requestline == null) {
        throw new IllegalArgumentException("Request line may not be null");
    }
    String method = requestline.getMethod();
    String uri = requestline.getUri();
    return newHttpRequest(method, uri);
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:10,代码来源:UpnpHttpRequestFactory.java

示例15: transformRequest

import org.apache.http.RequestLine; //导入方法依赖的package包/类
private static Request transformRequest(HttpRequest request) {
  Request.Builder builder = new Request.Builder();

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

  for (Header header : request.getAllHeaders()) {
    builder.header(header.getName(), 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);

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

  return builder.build();
}
 
开发者ID:NannanZ,项目名称:spdymcsclient,代码行数:29,代码来源:OkApacheClient.java


注:本文中的org.apache.http.RequestLine.getMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。