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