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


Java RequestLine类代码示例

本文整理汇总了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"));
}
 
开发者ID:facetome,项目名称:smart_plan,代码行数:22,代码来源:DatabaseDataRequestHandler.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:RequestWrapper.java

示例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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:BasicLineParser.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"
    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

示例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");
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:DefaultHttpRequestFactory.java

示例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);
        }
    };

}
 
开发者ID:cab404,项目名称:maud,代码行数:17,代码来源:Providers.java

示例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());
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:25,代码来源:BasicLineFormatterHC4.java

示例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();
}
 
开发者ID:Nike-Inc,项目名称:wingtips,代码行数:23,代码来源:WingtipsHttpClientBuilderTest.java

示例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();
}
 
开发者ID:Nike-Inc,项目名称:wingtips,代码行数:19,代码来源:WingtipsApacheHttpClientInterceptorTest.java

示例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;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:CachingHttpClient.java

示例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;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:17,代码来源:HttpRequestWrapper.java

示例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;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:25,代码来源:RequestWrapper.java

示例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();
        }
    };
}
 
开发者ID:soabase,项目名称:soabase,代码行数:25,代码来源:WrappedHttpRequest.java

示例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;
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:26,代码来源:RequestWrapper.java

示例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;
}
 
开发者ID:SanaMobile,项目名称:sana.mobile,代码行数:18,代码来源:DispatchRequestFactory.java


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