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


Java HttpUriRequest.getURI方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:PaleoCrafter,项目名称:CurseSync,代码行数:25,代码来源:CurseAPI.java

示例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.");
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:29,代码来源:ImmersionHttpClient.java

示例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;
}
 
开发者ID:aws,项目名称:aws-xray-sdk-java,代码行数:16,代码来源:TracedHttpClient.java

示例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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:AutoRetryHttpClient.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:AbstractHttpClient.java

示例6: getHttpHost

import org.apache.http.client.methods.HttpUriRequest; //导入方法依赖的package包/类
HttpHost getHttpHost(HttpUriRequest request) {
    URI uri = request.getURI();
    return URIUtils.extractHost(uri);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:DecompressingHttpClient.java

示例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();
}
 
开发者ID:SlotNSlot,项目名称:SlotNSlot_Android,代码行数:58,代码来源:AndroidHttpClient.java


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