本文整理汇总了Java中org.apache.http.RequestLine类的典型用法代码示例。如果您正苦于以下问题:Java RequestLine类的具体用法?Java RequestLine怎么用?Java RequestLine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RequestLine类属于org.apache.http包,在下文中一共展示了RequestLine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import org.apache.http.RequestLine; //导入依赖的package包/类
@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"));
}
示例2: 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;
}
示例3: parseRequestLine
import org.apache.http.RequestLine; //导入依赖的package包/类
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);
}
示例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"
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: 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");
}
}
示例6: regen
import org.apache.http.RequestLine; //导入依赖的package包/类
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);
}
};
}
示例7: 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());
}
示例8: beforeMethod
import org.apache.http.RequestLine; //导入依赖的package包/类
@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();
}
示例9: beforeMethod
import org.apache.http.RequestLine; //导入依赖的package包/类
@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();
}
示例10: clientRequestsOurOptions
import org.apache.http.RequestLine; //导入依赖的package包/类
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;
}
示例11: getRequestLine
import org.apache.http.RequestLine; //导入依赖的package包/类
@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;
}
示例12: 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;
}
示例13: getRequestLine
import org.apache.http.RequestLine; //导入依赖的package包/类
@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();
}
};
}
示例14: 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;
}
示例15: newHttpRequest
import org.apache.http.RequestLine; //导入依赖的package包/类
@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;
}