本文整理汇总了Java中org.apache.http.RequestLine.getUri方法的典型用法代码示例。如果您正苦于以下问题:Java RequestLine.getUri方法的具体用法?Java RequestLine.getUri怎么用?Java RequestLine.getUri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.RequestLine
的用法示例。
在下文中一共展示了RequestLine.getUri方法的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: 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());
}
示例4: 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;
}
示例5: 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;
}
示例6: 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);
}
}
示例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: 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();
}
示例9: getSubspanSpanName
import org.apache.http.RequestLine; //导入方法依赖的package包/类
/**
* Returns the name that should be used for the subspan surrounding the given request. This method returns {@code
* apachehttpclient_downstream_call-[HTTP_METHOD]_[REQUEST_URI]} with any query string stripped, e.g. for a GET
* call to https://foo.bar/baz?stuff=things, this would return {@code
* "apachehttpclient_downstream_call-GET_https://foo.bar/baz"}.
*
* @param request The request that is about to be executed.
* @return The name that should be used for the subspan surrounding the request.
*/
public static String getSubspanSpanName(HttpRequest request) {
RequestLine requestLine = request.getRequestLine();
String uri = requestLine.getUri();
if (request instanceof HttpRequestWrapper && uri.startsWith("/")) {
HttpRequestWrapper wrapper = (HttpRequestWrapper) request;
uri = wrapper.getTarget().toURI() + uri;
}
return HttpRequestTracingUtils.getSubspanSpanNameForHttpRequest(
"apachehttpclient_downstream_call", requestLine.getMethod(), uri
);
}
示例10: 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);
}
示例11: HttpRequestParcel
import org.apache.http.RequestLine; //导入方法依赖的package包/类
public HttpRequestParcel(HttpUriRequest request){
RequestLine line = request.getRequestLine();
uri = line.getUri();
method = line.getMethod();
headers = new Bundle();
for(Header header:request.getAllHeaders()){
headers.putString(header.getName(), header.getValue());
}
params = new Bundle();
entity = null;
files = new Bundle();
}
示例12: newHttpRequest
import org.apache.http.RequestLine; //导入方法依赖的package包/类
@Override
public HttpRequest newHttpRequest(RequestLine requestLine)
throws MethodNotSupportedException {
String method = requestLine.getMethod();
String uri = requestLine.getUri();
return this.newHttpRequest(method, uri);
}
示例13: getUri
import org.apache.http.RequestLine; //导入方法依赖的package包/类
private static String getUri(RequestLine requestLine) {
if (requestLine.getUri().charAt(0) != '/') {
return "/" + requestLine.getUri();
}
return requestLine.getUri();
}
示例14: getHttpMessage
import org.apache.http.RequestLine; //导入方法依赖的package包/类
private HttpMessage getHttpMessage(final byte[] data) {
final HttpParams httpParams = new BasicHttpParams();
final AbstractSessionInputBuffer inputBuffer = new AbstractSessionInputBuffer() {
{
init(new ByteArrayInputStream(data), 128, httpParams);
}
@Override
public boolean isDataAvailable(int i) throws IOException {
return this.hasBufferedData();
}
};
final HttpRequestFactory msearchRequestFactory = new HttpRequestFactory() {
@Override
public HttpRequest newHttpRequest(RequestLine requestLine) throws MethodNotSupportedException {
if (!requestLine.getMethod().equalsIgnoreCase("m-search"))
throw new MethodNotSupportedException("Invalid method: " + requestLine.getMethod());
if (!requestLine.getUri().equals("*"))
throw new MethodNotSupportedException("Invalid URI: " + requestLine.getUri());
return new BasicHttpRequest(requestLine);
}
@Override
public HttpRequest newHttpRequest(String method, String uri) throws MethodNotSupportedException {
if (!method.equalsIgnoreCase("m-search"))
throw new MethodNotSupportedException("Invalid method: " + method);
if (!uri.equals("*"))
throw new MethodNotSupportedException("Invalid URI: " + uri);
return new BasicHttpRequest(method, uri);
}
};
HttpRequestParser requestParser = new HttpRequestParser(inputBuffer, null, msearchRequestFactory, httpParams);
try {
return requestParser.parse();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例15: newHttpRequest
import org.apache.http.RequestLine; //导入方法依赖的package包/类
public HttpRequest newHttpRequest(RequestLine requestLine)
throws MethodNotSupportedException {
String method = requestLine.getMethod();
String uri = requestLine.getUri();
return newHttpRequest(method, uri);
}