本文整理汇总了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;
}
示例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;
}
示例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));
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}