本文整理汇总了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;
}
示例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());
}
示例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");
}
}
示例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());
}
示例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;
}
示例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;
}
示例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);
}
}
示例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");
}
}
示例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);
}
}
示例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();
}
示例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();
}
示例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();
}
示例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");
}
}
示例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);
}
示例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();
}