com.mashape.unirest.request.HttpRequest.header()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中com.mashape.unirest.request.HttpRequest.header()方法的一些代码示例,展示了HttpRequest.header()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.header()方法的具体详情如下:
包路径:com.mashape.unirest.request.HttpRequest
类名称:HttpRequest
方法名:header

HttpRequest.header介绍

暂无

代码示例

代码示例来源:origin: Kong/unirest-java

@Override
public HttpRequestWithBody header(String name, String value) {
  return (HttpRequestWithBody) super.header(name, value);
}

代码示例来源:origin: CognitiveJ/cognitivej

private T doWork() {
  try {
    setupErrorHandlers();
    WorkingContext workingContext = workingContext();
    HttpRequest builtRequest = buildUnirest(workingContext)
        .queryString(workingContext.getQueryParams())
        .headers(workingContext.getHeaders()).header("Ocp-Apim-Subscription-Key", cognitiveContext.subscriptionKey);
    if (!workingContext.getHttpMethod().equals(HttpMethod.GET) && workingContext().getPayload().size() > 0) {
      buildBody((HttpRequestWithBody) builtRequest);
    }
    HttpResponse response;
    if (typedResponse() == InputStream.class)
      response = builtRequest.asBinary();
    else
      response = builtRequest.asString();
    checkForError(response);
    return postProcess(typeResponse(response.getBody()));
  } catch (UnirestException | IOException e) {
    throw new CognitiveException(e);
  }
}

代码示例来源:origin: Kong/unirest-java

@Override
public GetRequest header(String name, String value) {
  return (GetRequest) super.header(name, value);
}

代码示例来源:origin: Kong/unirest-java

public HttpRequest headers(Map<String, String> headers) {
  if (headers != null) {
    for (Map.Entry<String, String> entry : headers.entrySet()) {
      header(entry.getKey(), entry.getValue());
    }
  }
  return this;
}

代码示例来源:origin: Kong/unirest-java

public HttpRequest basicAuth(String username, String password) {
  header("Authorization", "Basic " + Base64Coder.encodeString(username + ":" + password));
  return this;
}

代码示例来源:origin: Kong/unirest-java

Set<Entry<String, String>> entrySet = ((Map<String, String>) defaultHeaders).entrySet();
for (Entry<String, String> entry : entrySet) {
  request.header(entry.getKey(), entry.getValue());
request.header(USER_AGENT_HEADER, USER_AGENT);
request.header(ACCEPT_ENCODING_HEADER, "gzip");

代码示例来源:origin: com.mashape.unirest/unirest-java

@Override
public GetRequest header(String name, String value) {
  return (GetRequest) super.header(name, value);
}

代码示例来源:origin: com.github.bingoohuang/unirest-java

@Override
public GetRequest header(String name, String value) {
  return (GetRequest) super.header(name, value);
}

代码示例来源:origin: com.mashape.unirest/unirest-java

@Override
public HttpRequestWithBody header(String name, String value) {
  return (HttpRequestWithBody) super.header(name, value);
}

代码示例来源:origin: com.github.bingoohuang/unirest-java

@Override
public HttpRequestWithBody header(String name, String value) {
  return (HttpRequestWithBody) super.header(name, value);
}

代码示例来源:origin: com.mashape.unirest/unirest-java

public HttpRequest headers(Map<String, String> headers) {
  if (headers != null) {
    for (Map.Entry<String, String> entry : headers.entrySet()) {
      header(entry.getKey(), entry.getValue());
    }
  }
  return this;
}

代码示例来源:origin: com.github.bingoohuang/unirest-java

public HttpRequest headers(Map<String, String> headers) {
  if (headers != null) {
    for (Map.Entry<String, String> entry : headers.entrySet()) {
      header(entry.getKey(), entry.getValue());
    }
  }
  return this;
}

代码示例来源:origin: net.dv8tion/JDA

private <T extends HttpRequest> T addHeaders(T request)
  {
    if (api.getAuthToken() != null)
    {
      request.header("authorization", api.getAuthToken());
    }
    if (!(request instanceof GetRequest))
    {
      request.header("Content-Type", "application/json");
    }
    request.header("user-agent", USER_AGENT);
    request.header("Accept-Encoding", "gzip");
    return request;
  }
}

代码示例来源:origin: com.mashape.unirest/unirest-java

public HttpRequest basicAuth(String username, String password) {
  header("Authorization", "Basic " + Base64Coder.encodeString(username + ":" + password));
  return this;
}

代码示例来源:origin: Apicurio/apicurio-studio

/**
 * @see io.apicurio.hub.api.connectors.AbstractSourceConnector#addSecurityTo(com.mashape.unirest.request.HttpRequest)
 */
@Override
protected void addSecurityTo(HttpRequest request) throws SourceConnectorException {
  String idpToken = getExternalToken();
  request.header("Authorization", "Bearer " + idpToken);
}

代码示例来源:origin: com.github.bingoohuang/unirest-java

public HttpRequest basicAuth(String username, String password) {
  header("Authorization", "Basic " + Base64Coder.encodeString(username + ":" + password));
  return this;
}

代码示例来源:origin: Apicurio/apicurio-studio

/**
 * Adds security information to the http request.
 * @param request
 */
@Override
protected void addSecurityTo(HttpRequest request) throws SourceConnectorException {
  if (this.getExternalTokenType() == TOKEN_TYPE_BASIC) {
    request.header("Authorization", "Basic " + getExternalToken());
  }
  if (this.getExternalTokenType() == TOKEN_TYPE_OAUTH) {
    request.header("Authorization", "Bearer " + getExternalToken());
  }
}

代码示例来源:origin: com.github.bingoohuang/blackcat-instrument

public static void prepareRPC(HttpRequest httpRequest) {
  val context = threadLocal.get();
  if (context == null) return;
  val httpMethod = httpRequest.getHttpMethod().name();
  trace("RPC", httpMethod + ":" + httpRequest.getUrl());
  httpRequest.header(BLACKCAT_TRACEID, context.getTraceId());
  val linkId = context.getParentLinkId() + String.format(".%06d", context.getSubLinkId());
  httpRequest.header(BLACKCAT_LINKID, linkId);
}

代码示例来源:origin: com.mashape.unirest/unirest-java

Set<Entry<String, String>> entrySet = ((Map<String, String>) defaultHeaders).entrySet();
for (Entry<String, String> entry : entrySet) {
  request.header(entry.getKey(), entry.getValue());
request.header(USER_AGENT_HEADER, USER_AGENT);
request.header(ACCEPT_ENCODING_HEADER, "gzip");

代码示例来源:origin: gradle.plugin.GoBqa/gradle-plugin

HttpRequest getRequestNoBody;
getRequestNoBody = Unirest.get(url);
getRequestNoBody = (contentType != null) ? getRequestNoBody.header("content-type", contentType) : getRequestNoBody;
getRequestNoBody = (basicAuth != null) ? getRequestNoBody.basicAuth(basicAuth.username, basicAuth.password) : getRequestNoBody;
Enumeration<?> e = headers.propertyNames();
  String value = headers.getProperty(headName);
  getRequestNoBody = getRequestNoBody.header(headName, value);

相关文章