本文整理了Java中org.apache.http.client.fluent.Request.Get
方法的一些代码示例,展示了Request.Get
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.Get
方法的具体详情如下:
包路径:org.apache.http.client.fluent.Request
类名称:Request
方法名:Get
暂无
代码示例来源:origin: dreamhead/moco
public HttpResponse getResponse(final String url) throws IOException {
return execute(Request.Get(url));
}
代码示例来源:origin: dreamhead/moco
public int getForStatus(final String url) throws IOException {
return execute(Request.Get(url)).getStatusLine().getStatusCode();
}
代码示例来源:origin: dreamhead/moco
private Request getRequest(final String url, final ImmutableMultimap<String, String> headers) {
Request request = Request.Get(url);
for (Map.Entry<String, String> entry : headers.entries()) {
request = request.addHeader(entry.getKey(), entry.getValue());
}
return request;
}
代码示例来源:origin: dreamhead/moco
@Override
public void run() throws IOException {
Request request = Request.Get(root());
Header header = helper.execute(request).getFirstHeader("foo");
assertThat(header.getValue(), is("foo.response"));
}
});
代码示例来源:origin: dreamhead/moco
public byte[] getAsBytes(final String url) throws IOException {
return EntityUtils.toByteArray(execute(Request.Get(url)).getEntity());
}
代码示例来源:origin: dreamhead/moco
@Override
public void run() throws Exception {
HttpResponse response = helper.execute(Request.Get(remoteUrl("/proxy")));
assertThat(response.getFirstHeader("Date"), nullValue());
assertThat(response.getFirstHeader("Server"), nullValue());
}
});
代码示例来源:origin: twosigma/beakerx
private Map getResult(LinkedList<String> parts, String last) throws IOException {
String uri = getUrl(parts, last);
String valueString = Request
.Get(uri)
.execute()
.returnContent()
.asString();
return fromJson(valueString);
}
代码示例来源:origin: dreamhead/moco
@Override
public void run() throws Exception {
Header header = helper.execute(Request.Get(remoteUrl("/template")).version(HttpVersion.HTTP_1_0)).getFirstHeader("foo");
assertThat(header.getValue(), is("GET"));
}
});
代码示例来源:origin: dreamhead/moco
@Override
public void run() throws IOException {
Request request = Request.Get(remoteUrl("/proxy")).addHeader("foo", "foo");
String fooHeader = helper.execute(request).getFirstHeader("foo").getValue();
assertThat(fooHeader, is("foo_header"));
}
});
代码示例来源:origin: dreamhead/moco
public String getWithVersion(final String url, final HttpVersion version) throws IOException {
return executeAsString(Request.Get(url).version(version));
}
代码示例来源:origin: dreamhead/moco
@Override
public void run() throws Exception {
Request request = Request.Get(root()).addHeader("Connection", "close");
HttpResponse response = helper.execute(request);
assertThat(response.getFirstHeader("Connection"), nullValue());
}
});
代码示例来源:origin: dreamhead/moco
@Override
public void run() throws Exception {
Request request = Request.Get(root()).version(HttpVersion.HTTP_1_0).addHeader("Connection", "keep-alive");
HttpResponse response = helper.execute(request);
String connection = response.getFirstHeader("Connection").getValue();
assertThat(connection, is("keep-alive"));
}
});
代码示例来源:origin: dreamhead/moco
@Override
public void run() throws Exception {
Request request = Request.Get(root()).version(HttpVersion.HTTP_1_1).addHeader("Connection", "keep-alive");
HttpResponse response = helper.execute(request);
assertThat(response.getFirstHeader("Connection"), nullValue());
}
});
代码示例来源:origin: dreamhead/moco
@Test
public void should_return_header_from_template() throws IOException {
runWithConfiguration("template.json");
Header header = helper.execute(Request.Get(remoteUrl("/header_template")).addHeader("foo", "bar"))
.getFirstHeader("foo");
assertThat(header.getValue(), is("bar"));
}
代码示例来源:origin: dreamhead/moco
@Override
public void run() throws Exception {
ProtocolVersion version = helper.execute(Request.Get(remoteUrl("/template"))
.version(HttpVersion.HTTP_1_0))
.getProtocolVersion();
assertThat(version.toString(), is("HTTP/1.0"));
}
});
代码示例来源:origin: dreamhead/moco
@Override
public void run() throws IOException {
ProtocolVersion version10 = helper.execute(Request.Get(root())
.version(HttpVersion.HTTP_1_0))
.getProtocolVersion();
assertThat(version10.getMajor(), is(1));
assertThat(version10.getMinor(), is(0));
ProtocolVersion version11 = helper.execute(Request.Get(root())
.version(HttpVersion.HTTP_1_1))
.getProtocolVersion();
assertThat(version11.getMajor(), is(1));
assertThat(version11.getMinor(), is(1));
}
});
代码示例来源:origin: dreamhead/moco
@Override
public void run() throws IOException {
ProtocolVersion version10 = helper.execute(Request.Get(root())
.version(HttpVersion.HTTP_1_0))
.getProtocolVersion();
assertThat(version10.getMajor(), is(1));
assertThat(version10.getMinor(), is(0));
ProtocolVersion version11 = helper.execute(Request.Get(root())
.version(HttpVersion.HTTP_1_1))
.getProtocolVersion();
assertThat(version11.getMajor(), is(1));
assertThat(version11.getMinor(), is(1));
}
});
代码示例来源:origin: dreamhead/moco
@Test
public void should_return_specified_version_for_request() throws IOException {
runWithConfiguration("foo.json");
ProtocolVersion version = helper.execute(Request.Get(remoteUrl("/version10"))).getProtocolVersion();
assertThat(version.getProtocol(), is("HTTP"));
assertThat(version.getMajor(), is(1));
assertThat(version.getMinor(), is(0));
}
代码示例来源:origin: dreamhead/moco
@Override
public void run() throws IOException {
HttpResponse response10 = helper.execute(Request.Get(remoteUrl("/proxy"))
.version(HttpVersion.HTTP_1_0));
assertThat(response10.getProtocolVersion().toString(), is(HttpVersion.HTTP_1_0.toString()));
HttpResponse response11 = helper.execute(Request.Get(remoteUrl("/proxy"))
.version(HttpVersion.HTTP_1_1));
assertThat(response11.getProtocolVersion().toString(), is(HttpVersion.HTTP_1_1.toString()));
HttpResponse response09 = helper.execute(Request.Get(remoteUrl("/proxy"))
.version(HttpVersion.HTTP_0_9));
assertThat(response09.getProtocolVersion().toString(), is(HttpVersion.HTTP_1_0.toString()));
}
});
代码示例来源:origin: dreamhead/moco
@Test
public void should_return_version_from_template() throws IOException {
runWithConfiguration("template.json");
ProtocolVersion version = helper.execute(Request.Get(remoteUrl("/version_template"))
.version(HttpVersion.HTTP_1_0))
.getProtocolVersion();
assertThat(version.toString(), is("HTTP/1.0"));
}
内容来源于网络,如有侵权,请联系作者删除!