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


Java HttpRequest.header方法代码示例

本文整理汇总了Java中com.mashape.unirest.request.HttpRequest.header方法的典型用法代码示例。如果您正苦于以下问题:Java HttpRequest.header方法的具体用法?Java HttpRequest.header怎么用?Java HttpRequest.header使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mashape.unirest.request.HttpRequest的用法示例。


在下文中一共展示了HttpRequest.header方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAcceptHeader

import com.mashape.unirest.request.HttpRequest; //导入方法依赖的package包/类
private static HttpRequest setAcceptHeader(Method method, HttpRequest request) {
    if (isPrimitiveOrString(returnTypeof(method))) {
        request = request.header("accept", "text/plain");

    } else {
        request = request.header("accept", "application/json");

    }
    return request;
}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:11,代码来源:Rest.java

示例2: config

import com.mashape.unirest.request.HttpRequest; //导入方法依赖的package包/类
/**
 * @param httpRequest
 * @param params
 */
private static void config(final HttpRequest httpRequest, final Map<String, String> params) {
    httpRequest.routeParam("api_token", SocceramaAPIClient.getInstance().getApiToken());

    if (params != null && !params.isEmpty()) {
        for (Map.Entry<String, String> param : params.entrySet()) {
            httpRequest.routeParam(param.getKey(), param.getValue());
        }
    } else {
        httpRequest.routeParam("includes", "");
    }

    httpRequest.header("Accept", "application/json");
}
 
开发者ID:kevinsamyn,项目名称:soccerama-pro-client,代码行数:18,代码来源:SocceramaRest.java

示例3: signReq

import com.mashape.unirest.request.HttpRequest; //导入方法依赖的package包/类
private void signReq(SignProvider signProvider, Map<String, Object> requestParams, HttpRequest httpRequest) {
    if (signProvider == null) {
        httpRequest.header("hict", Now.now());
        httpRequest.header("hici", uuid);
    } else {
        signProvider.sign(apiClass, uuid, requestParams, httpRequest);
    }
}
 
开发者ID:bingoohuang,项目名称:spring-rest-client,代码行数:9,代码来源:RestLog.java

示例4: sign

import com.mashape.unirest.request.HttpRequest; //导入方法依赖的package包/类
@Override
public void sign(Class<?> apiClass, String uuid,
                 Map<String, Object> requestParams,
                 HttpRequest httpRequest) {

    httpRequest.header("hict", Now.now());
    httpRequest.header("hici", uuid);
    httpRequest.header("hick", clientKey);
    httpRequest.header("hisa", "hmac");
    httpRequest.header("hisv", hmac(apiClass, requestParams, httpRequest));
}
 
开发者ID:bingoohuang,项目名称:spring-rest-client,代码行数:12,代码来源:DefaultSignProvider.java

示例5: processRequest

import com.mashape.unirest.request.HttpRequest; //导入方法依赖的package包/类
private void processRequest(HttpRequest request) {
    request.header("Authorization", token);
    if (useJson) request.header("Content-Type", "application/json");
}
 
开发者ID:AlienIdeology,项目名称:J-Cord,代码行数:5,代码来源:Requester.java

示例6: authorizeHttpRequest

import com.mashape.unirest.request.HttpRequest; //导入方法依赖的package包/类
/**
 * Adds the appropriate authorization data to the given pre-built request.
 *
 * @param request The request to modify
 */
private void authorizeHttpRequest(HttpRequest request) {
    if (token != null) {
        request.header("X-Consul-Token", token);
    }
}
 
开发者ID:jackprice,项目名称:gatekeeper,代码行数:11,代码来源:Client.java

示例7: get

import com.mashape.unirest.request.HttpRequest; //导入方法依赖的package包/类
public static Object get(String endpoint, Method method, Object[] args) throws UnirestException {

        HttpRequest request = Unirest.get(endpoint + "/" + restPathFor(method));

        MethodToRestParameters params = new MethodToRestParameters(method);

        request = setAcceptHeader(method, request);

        request = request.header("Content-Type", "application/json");

        request = buildQueryStringFromHeaders(params.getHeaders(), args, 0, request);

        return executeRequest(method, request);
    }
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:15,代码来源:Rest.java

示例8: addHeader

import com.mashape.unirest.request.HttpRequest; //导入方法依赖的package包/类
/**
 * Convenience method for adding a header to the HTTP Request
 * @param request the HTTP request
 * @param key the name of the header to add
 * @param value the value of the header to add
 */
protected void addHeader(final HttpRequest request, final String key, final String value) {
    request.header(key, value);
}
 
开发者ID:shaneagibson,项目名称:hmrc4j,代码行数:10,代码来源:API.java


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