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


Java BasicRequestLine类代码示例

本文整理汇总了Java中org.apache.http.message.BasicRequestLine的典型用法代码示例。如果您正苦于以下问题:Java BasicRequestLine类的具体用法?Java BasicRequestLine怎么用?Java BasicRequestLine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getRequestLine

import org.apache.http.message.BasicRequestLine; //导入依赖的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

示例2: newHttpRequest

import org.apache.http.message.BasicRequestLine; //导入依赖的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

示例3: getCoapRequestLocalResourceTest

import org.apache.http.message.BasicRequestLine; //导入依赖的package包/类
@Test
public final void getCoapRequestLocalResourceTest() throws TranslationException {
	String resourceName = "localResource";
	String resourceString = "/" + resourceName;

	for (String httpMethod : COAP_METHODS) {
		// create the http request
		RequestLine requestLine = new BasicRequestLine(httpMethod, resourceString, HttpVersion.HTTP_1_1);
		HttpRequest httpRequest = new BasicHttpRequest(requestLine);

		// translate the request
		Request coapRequest = HttpTranslator.getCoapRequest(httpRequest, PROXY_RESOURCE, true);
		assertNotNull(coapRequest);

		// check the method translation
		int coapMethod = Integer.parseInt(HttpTranslator.HTTP_TRANSLATION_PROPERTIES.getProperty("http.request.method." + httpMethod));
		assertTrue(coapRequest.getCode() == coapMethod);

		// check the uri-path
		String uriPath = coapRequest.getFirstOption(OptionNumberRegistry.URI_PATH).getStringValue();
		assertEquals(uriPath, resourceName);

		// check the absence of the proxy-uri option
		assertNull(coapRequest.getFirstOption(OptionNumberRegistry.PROXY_URI));
	}
}
 
开发者ID:Orange-OpenSource,项目名称:holico,代码行数:27,代码来源:HttpTranslatorTest.java

示例4: getHttpRequest

import org.apache.http.message.BasicRequestLine; //导入依赖的package包/类
private HttpRequest getHttpRequest(String user, String pass){
	HttpRequestFactory factory = new DefaultHttpRequestFactory();
	HttpRequest req = null;
	String base64 = new String(Base64.encodeBase64(
			user.concat(":").concat(pass).getBytes()));
	try {
		req = factory.newHttpRequest(
				new BasicRequestLine("POST", "https://localhost:8444/",
						HttpVersion.HTTP_1_1));
		req.addHeader("Accept-Encoding", "gzip,deflate");
		req.addHeader("Content-Type", "application/soap+xml;charset=UTF-8");
		req.addHeader("User-Agent", "IROND Testsuite/1.0");
		req.addHeader("Host", "localhost:8444");
		req.addHeader("Content-Length", "198");
		req.addHeader("Authorization", "Basic "+base64);
	} catch (MethodNotSupportedException e) {
		e.printStackTrace();
	}
	return req;
}
 
开发者ID:trustathsh,项目名称:irond,代码行数:21,代码来源:BasicAccessAuthenticationTest.java

示例5: mockResponse

import org.apache.http.message.BasicRequestLine; //导入依赖的package包/类
private static Response mockResponse() {
    ProtocolVersion protocolVersion = new ProtocolVersion("HTTP", 1, 1);
    RequestLine requestLine = new BasicRequestLine("GET", "/", protocolVersion);
    StatusLine statusLine = new BasicStatusLine(protocolVersion, 200, "OK");
    HttpResponse httpResponse = new BasicHttpResponse(statusLine);
    return new Response(requestLine, new HttpHost("localhost", 9200), httpResponse);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:SyncResponseListenerTests.java

示例6: getRequestLine

import org.apache.http.message.BasicRequestLine; //导入依赖的package包/类
public RequestLine getRequestLine() {
    String method = getMethod();
    ProtocolVersion ver = getProtocolVersion();
    URI uri = getURI();
    String uritext = null;
    if (uri != null) {
        uritext = uri.toASCIIString();
    }
    if (uritext == null || uritext.length() == 0) {
        uritext = "/";
    }
    return new BasicRequestLine(method, uritext, ver);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:HttpRequestBase.java

示例7: getRequestLine

import org.apache.http.message.BasicRequestLine; //导入依赖的package包/类
public RequestLine getRequestLine() {
    String method = getMethod();
    ProtocolVersion ver = getProtocolVersion();
    String uritext = null;
    if (uri != null) {
        uritext = uri.toASCIIString();
    }
    if (uritext == null || uritext.length() == 0) {
        uritext = "/";
    }
    return new BasicRequestLine(method, uritext, ver);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:RequestWrapper.java

示例8: setUp

import org.apache.http.message.BasicRequestLine; //导入依赖的package包/类
@Before
public void setUp() throws IllegalStateException, IOException {
    this.interceptor = new HmacMmv2Interceptor(API_KEY, SECRET_KEY);

    request = Mockito.mock(HttpEntityEnclosingRequest.class);
    Mockito.when(request.getFirstHeader(HTTP.DATE_HEADER)).thenReturn(new BasicHeader("", DATE_HEADER));
    Mockito.when(request.getRequestLine()).thenReturn(new BasicRequestLine("POST", "/v1/messages", HttpVersion.HTTP_1_1));
}
 
开发者ID:messagemedia,项目名称:messagemedia-rest-api-java-sdk,代码行数:9,代码来源:HmacMmv2InterceptorTest.java

示例9: getRequestLine

import org.apache.http.message.BasicRequestLine; //导入依赖的package包/类
public RequestLine getRequestLine() {
    String requestUri = null;
    if (this.uri != null) {
        requestUri = this.uri.toASCIIString();
    } else {
        requestUri = this.original.getRequestLine().getUri();
    }
    if (requestUri == null || requestUri.length() == 0) {
        requestUri = "/";
    }
    return new BasicRequestLine(this.method, requestUri, getProtocolVersion());
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:13,代码来源:HttpRequestWrapper.java

示例10: getRequestLine

import org.apache.http.message.BasicRequestLine; //导入依赖的package包/类
public RequestLine getRequestLine() {
    final String method = getMethod();
    final ProtocolVersion ver = getProtocolVersion();
    final URI uri = getURI();
    String uritext = null;
    if (uri != null) {
        uritext = uri.toASCIIString();
    }
    if (uritext == null || uritext.length() == 0) {
        uritext = "/";
    }
    return new BasicRequestLine(method, uritext, ver);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:14,代码来源:HttpRequestBaseHC4.java

示例11: getRequestLine

import org.apache.http.message.BasicRequestLine; //导入依赖的package包/类
@Override
public RequestLine getRequestLine() {
    final String method = getMethod();
    final ProtocolVersion ver = getProtocolVersion();
    final URI uriCopy = getURI(); // avoids possible window where URI could be changed
    String uritext = null;
    if (uriCopy != null) {
        uritext = uriCopy.toASCIIString();
    }
    if (uritext == null || uritext.isEmpty()) {
        uritext = "/";
    }
    return new BasicRequestLine(method, uritext, ver);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:15,代码来源:HttpRequestBase.java

示例12: getRequestLine

import org.apache.http.message.BasicRequestLine; //导入依赖的package包/类
@Override
public RequestLine getRequestLine() {
    final ProtocolVersion ver = getProtocolVersion();
    String uritext = null;
    if (uri != null) {
        uritext = uri.toASCIIString();
    }
    if (uritext == null || uritext.isEmpty()) {
        uritext = "/";
    }
    return new BasicRequestLine(getMethod(), uritext, ver);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:13,代码来源:RequestWrapper.java

示例13: getRequestLine

import org.apache.http.message.BasicRequestLine; //导入依赖的package包/类
@Override
public RequestLine getRequestLine() {
    final ProtocolVersion ver = getProtocolVersion();
    final URI uriCopy = getURI();
    String uritext = null;
    if (uriCopy != null) {
        uritext = uriCopy.toASCIIString();
    }
    if (uritext == null || uritext.isEmpty()) {
        uritext = "/";
    }
    return new BasicRequestLine(getMethod(), uritext, ver);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:14,代码来源:InternalHttpRequest.java

示例14: getCoapRequestConnectMethodTest

import org.apache.http.message.BasicRequestLine; //导入依赖的package包/类
@Test(expected = TranslationException.class)
public final void getCoapRequestConnectMethodTest() throws TranslationException {
	RequestLine requestLine = new BasicRequestLine("connect", "http://localhost", HttpVersion.HTTP_1_1);
	HttpRequest httpRequest = new BasicHttpRequest(requestLine);

	HttpTranslator.getCoapRequest(httpRequest, "", true);
}
 
开发者ID:Orange-OpenSource,项目名称:holico,代码行数:8,代码来源:HttpTranslatorTest.java

示例15: getCoapRequestOptionsMethodTest

import org.apache.http.message.BasicRequestLine; //导入依赖的package包/类
@Test(expected = TranslationException.class)
public final void getCoapRequestOptionsMethodTest() throws TranslationException {
	RequestLine requestLine = new BasicRequestLine("options", "http://localhost", HttpVersion.HTTP_1_1);
	HttpRequest httpRequest = new BasicHttpRequest(requestLine);

	HttpTranslator.getCoapRequest(httpRequest, "", true);
}
 
开发者ID:Orange-OpenSource,项目名称:holico,代码行数:8,代码来源:HttpTranslatorTest.java


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