本文整理汇总了Java中org.apache.http.client.methods.HttpUriRequest.getURI方法的典型用法代码示例。如果您正苦于以下问题:Java HttpUriRequest.getURI方法的具体用法?Java HttpUriRequest.getURI怎么用?Java HttpUriRequest.getURI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.client.methods.HttpUriRequest
的用法示例。
在下文中一共展示了HttpUriRequest.getURI方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getModSlug0
import org.apache.http.client.methods.HttpUriRequest; //导入方法依赖的package包/类
@Nullable
private String getModSlug0(int id)
{
try
{
log.debug("Getting mod slug from server...");
URI uri = getURI(CURSEFORGE_URL, String.format(PROJECT_PATH, id), null);
HttpGet request = new HttpGet(uri.toURL().toString());
HttpContext context = new BasicHttpContext();
HttpResponse response = http.execute(request, context);
EntityUtils.consume(response.getEntity());
HttpUriRequest currentReq = (HttpUriRequest) context.getAttribute(HttpCoreContext.HTTP_REQUEST);
HttpHost currentHost = (HttpHost) context.getAttribute(HttpCoreContext.HTTP_TARGET_HOST);
String currentUrl = (currentReq.getURI().isAbsolute()) ? currentReq.getURI().toString() : (currentHost.toURI() + currentReq.getURI());
Splitter splitter = Splitter.on('/').omitEmptyStrings();
List<String> pathParts = splitter.splitToList(currentUrl);
return pathParts.get(pathParts.size() - 1);
}
catch (Exception e)
{
log.error("Failed to perform request from CurseForge site.", e);
return null;
}
}
示例2: if
import org.apache.http.client.methods.HttpUriRequest; //导入方法依赖的package包/类
private HttpResponse b0449щ0449щщ0449(HttpUriRequest httpUriRequest, Map map, int i) throws Exception {
URI uri = httpUriRequest.getURI();
String trim = uri.getHost() != null ? uri.getHost().trim() : "";
if (trim.length() > 0) {
httpUriRequest.setHeader("Host", trim);
}
if (map != null) {
for (Object next : map.entrySet()) {
if (((b04170417041704170417З + b0417ЗЗЗЗ0417) * b04170417041704170417З) % bЗ0417ЗЗЗ0417 != bЗЗЗЗЗ0417) {
b04170417041704170417З = 81;
bЗЗЗЗЗ0417 = 31;
}
Entry entry = (Entry) next;
httpUriRequest.setHeader((String) entry.getKey(), (String) entry.getValue());
}
}
Header[] allHeaders = httpUriRequest.getAllHeaders();
Log.d(b043D043Dнн043Dн, "request URI [" + httpUriRequest.getURI() + "]");
for (Object obj : allHeaders) {
Log.d(b043D043Dнн043Dн, "request header [" + obj.toString() + "]");
}
HttpConnectionParams.setSoTimeout(this.bнн043Dн043Dн.getParams(), i);
HttpResponse execute = this.bнн043Dн043Dн.execute(httpUriRequest);
if (execute != null) {
return execute;
}
throw new RuntimeException("Null response returned.");
}
示例3: determineTarget
import org.apache.http.client.methods.HttpUriRequest; //导入方法依赖的package包/类
public static HttpHost determineTarget(final HttpUriRequest request) throws ClientProtocolException {
// A null target may be acceptable if there is a default target.
// Otherwise, the null target is detected in the director.
HttpHost target = null;
final URI requestURI = request.getURI();
if (requestURI.isAbsolute()) {
target = URIUtils.extractHost(requestURI);
if (target == null) {
throw new ClientProtocolException("URI does not specify a valid host name: "
+ requestURI);
}
}
return target;
}
示例4: execute
import org.apache.http.client.methods.HttpUriRequest; //导入方法依赖的package包/类
public HttpResponse execute(HttpUriRequest request, HttpContext context)
throws IOException {
URI uri = request.getURI();
HttpHost httpHost = new HttpHost(uri.getHost(), uri.getPort(),
uri.getScheme());
return execute(httpHost, request, context);
}
示例5: determineTarget
import org.apache.http.client.methods.HttpUriRequest; //导入方法依赖的package包/类
private static HttpHost determineTarget(HttpUriRequest request) throws ClientProtocolException {
// A null target may be acceptable if there is a default target.
// Otherwise, the null target is detected in the director.
HttpHost target = null;
URI requestURI = request.getURI();
if (requestURI.isAbsolute()) {
target = URIUtils.extractHost(requestURI);
if (target == null) {
throw new ClientProtocolException(
"URI does not specify a valid host name: " + requestURI);
}
}
return target;
}
示例6: getHttpHost
import org.apache.http.client.methods.HttpUriRequest; //导入方法依赖的package包/类
HttpHost getHttpHost(HttpUriRequest request) {
URI uri = request.getURI();
return URIUtils.extractHost(uri);
}
示例7: toCurl
import org.apache.http.client.methods.HttpUriRequest; //导入方法依赖的package包/类
/**
* Generates a cURL command equivalent to the given request.
*/
private static String toCurl(HttpUriRequest request, boolean logAuthToken) throws IOException {
StringBuilder builder = new StringBuilder();
builder.append("curl ");
for (Header header: request.getAllHeaders()) {
if (!logAuthToken
&& (header.getName().equals("Authorization") ||
header.getName().equals("Cookie"))) {
continue;
}
builder.append("--header \"");
builder.append(header.toString().trim());
builder.append("\" ");
}
URI uri = request.getURI();
// If this is a wrapped request, use the URI from the original
// request instead. getURI() on the wrapper seems to return a
// relative URI. We want an absolute URI.
if (request instanceof RequestWrapper) {
HttpRequest original = ((RequestWrapper) request).getOriginal();
if (original instanceof HttpUriRequest) {
uri = ((HttpUriRequest) original).getURI();
}
}
builder.append("\"");
builder.append(uri);
builder.append("\"");
if (request instanceof HttpEntityEnclosingRequest) {
HttpEntityEnclosingRequest entityRequest =
(HttpEntityEnclosingRequest) request;
HttpEntity entity = entityRequest.getEntity();
if (entity != null && entity.isRepeatable()) {
if (entity.getContentLength() < 1024) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
entity.writeTo(stream);
String entityString = stream.toString();
// TODO: Check the content type, too.
builder.append(" --data-ascii \"")
.append(entityString)
.append("\"");
} else {
builder.append(" [TOO MUCH DATA TO INCLUDE]");
}
}
}
return builder.toString();
}