• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BasicRequestLine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getCoapRequestTraceMethodTest

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

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


示例17: getCoapRequestUnknownMethodTest

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

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


示例18: getCoapRequestTemplateTest

import org.apache.http.message.BasicRequestLine; //导入依赖的package包/类
/**
 * @param coapServerUri
 * @param uri
 * @throws TranslationException
 */
private void getCoapRequestTemplateTest(String coapServerUri, String uri) throws TranslationException {
	for (String httpMethod : COAP_METHODS) {
		// create the http request
		RequestLine requestLine = new BasicRequestLine(httpMethod, uri, 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 proxy-uri
		String proxyUri = coapRequest.getFirstOption(OptionNumberRegistry.PROXY_URI).getStringValue();

		if (!proxyUri.equals(coapServerUri)) {
			try {
				coapServerUri = URLDecoder.decode(coapServerUri, "UTF-8");
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		if (!coapServerUri.contains("coap://")) {
			coapServerUri = "coap://" + coapServerUri;
		}
		assertEquals(proxyUri, coapServerUri);

		// check the absence of the uri-* options
		assertNull(coapRequest.getFirstOption(OptionNumberRegistry.URI_PATH));
		assertNull(coapRequest.getFirstOption(OptionNumberRegistry.URI_HOST));
		assertNull(coapRequest.getFirstOption(OptionNumberRegistry.URI_QUERY));
		assertNull(coapRequest.getFirstOption(OptionNumberRegistry.URI_PORT));
	}
}
 
开发者ID:Orange-OpenSource,项目名称:holico,代码行数:42,代码来源:HttpTranslatorTest.java


示例19: HttpRequest

import org.apache.http.message.BasicRequestLine; //导入依赖的package包/类
public HttpRequest(final String method, final String url) {
	this.requestLine = new BasicRequestLine(method, url, PROTOCOL_VERSION);
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:4,代码来源:StringHttpMessages.java


示例20: HttpRequest

import org.apache.http.message.BasicRequestLine; //导入依赖的package包/类
public HttpRequest(final int maxNumberOfHeaders, final int maxLenghtOfHeader, final int pos) {
	this.requestLine = new BasicRequestLine("GET", RandomStringUtils.randomAlphabetic(RNG.nextInt(maxLenghtOfHeader) + 1), PROTOCOL_VERSION);
	Header[] headers = randomHeaders(maxNumberOfHeaders, maxLenghtOfHeader);
	headers[RNG.nextInt(headers.length)] = new BasicHeader("Position", Integer.toString(pos));
	this.setHeaders(headers);
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:7,代码来源:RandomTestMocks.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ListModel类代码示例发布时间:2022-05-21
下一篇:
Java HFileWriterV2类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap