com.github.kevinsawicki.http.HttpRequest.contentType()方法的使用及代码示例

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

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

HttpRequest.contentType介绍

[英]Get the 'Content-Type' header from the response
[中]从响应中获取“内容类型”标题

代码示例

代码示例来源:origin: com.restfuse/com.eclipsesource.restfuse

/**
 * Set the 'Content-Type' request header to the given value
 *
 * @param value
 * @return this request
 */
public HttpRequest contentType(final String value) {
 return contentType(value, null);
}

代码示例来源:origin: tcking/GiraffePlayer2

/**
 * Set the 'Content-Type' request header to the given value
 *
 * @param contentType
 * @return this request
 */
public HttpRequest contentType(final String contentType) {
  return contentType(contentType, null);
}

代码示例来源:origin: lkorth/httpebble-android

/**
 * Set the 'Content-Type' request header to the given value
 *
 * @param value
 * @return this request
 */
public HttpRequest contentType(final String value) {
  return contentType(value, null);
}

代码示例来源:origin: com.github.kevinsawicki/http-request

/**
 * Set the 'Content-Type' request header to the given value
 *
 * @param contentType
 * @return this request
 */
public HttpRequest contentType(final String contentType) {
 return contentType(contentType, null);
}

代码示例来源:origin: com.restfuse/com.eclipsesource.restfuse

private void addContentType( HttpRequest request ) {
 String type = mediaType != null ? mediaType : "*/*";
 request.contentType( type );
}

代码示例来源:origin: ihaolin/antares

private void setOptionalHeaders(HttpRequest request) {
  if (!Strings.isNullOrEmpty(contentType)){
    request.contentType(contentType, charset);
  }
  if (!Strings.isNullOrEmpty(accept)){
    request.accept(accept);
  }
}

代码示例来源:origin: com.restfuse/com.eclipsesource.restfuse

public ResponseImpl( HttpRequest request ) {
 body = request.body();
 contentType = request.contentType();
 headers = request.headers();
 code = request.code();
 url = request.getConnection().getURL().toString();
 request.disconnect();
}

代码示例来源:origin: me.hao0/common

private void setOptionalHeaders(HttpRequest request) {
  if (!Strings.isNullOrEmpty(contentType)){
    request.contentType(contentType, charset);
  }
  if (!Strings.isNullOrEmpty(accept)){
    request.accept(accept);
  }
}

代码示例来源:origin: no.cantara.base/Hystrix-BaseCommands

@Override
  protected HttpRequest dealWithRequestBeforeSend(HttpRequest request) {
    super.dealWithRequestBeforeSend(request);
//        request.getConnection().addRequestProperty("SOAPAction", SOAP_ACTION);
    String query = buildSoapXml();
    request.contentType("text/xml;charset=UTF-8").send(query);
    return request;
  }

代码示例来源:origin: ihaolin/common

private void setOptionalHeaders(HttpRequest request) {
  if (!Strings.isNullOrEmpty(contentType)){
    request.contentType(contentType, charset);
  }
  if (!Strings.isNullOrEmpty(accept)){
    request.accept(accept);
  }
}

代码示例来源:origin: com.github.kevinsawicki/http-request

/**
 * Start part of a multipart
 *
 * @return this request
 * @throws IOException
 */
protected HttpRequest startPart() throws IOException {
 if (!multipart) {
  multipart = true;
  contentType(CONTENT_TYPE_MULTIPART).openOutput();
  output.write("--" + BOUNDARY + CRLF);
 } else
  output.write(CRLF + "--" + BOUNDARY + CRLF);
 return this;
}

代码示例来源:origin: com.restfuse/com.eclipsesource.restfuse

/**
 * Start part of a multipart
 *
 * @return this request
 * @throws IOException
 */
protected HttpRequest startPart() throws IOException {
 if (!multipart) {
  multipart = true;
  contentType(CONTENT_TYPE_MULTIPART).openOutput();
  output.write("--" + BOUNDARY + CRLF);
 } else
  output.write(CRLF + "--" + BOUNDARY + CRLF);
 return this;
}

代码示例来源:origin: no.cantara.base/Hystrix-BaseCommands

protected HttpRequest dealWithRequestBeforeSend(HttpRequest request) {
  //CAN USE MULTIPART
  //JUST EXAMPLE
  //		HttpRequest request = HttpRequest.post("http://google.com");
  //		request.part("status[body]", "Making a multipart request");
  //		request.part("status[image]", new File("/home/kevin/Pictures/ide.png"));
  //OR SEND SOME DATA
  //request.send("name=huydo")
  //or something like
  if (getJsonBody() != null) {
    request.contentType("application/json").send(getJsonBody());
  }
  //request.contentType("application/json").send(applicationJson);
  return request;
}

代码示例来源:origin: tcking/GiraffePlayer2

/**
 * Start part of a multipart
 *
 * @return this request
 * @throws IOException
 */
protected HttpRequest startPart() throws IOException {
  if (!multipart) {
    multipart = true;
    contentType(CONTENT_TYPE_MULTIPART).openOutput();
    output.write("--" + BOUNDARY + CRLF);
  } else
    output.write(CRLF + "--" + BOUNDARY + CRLF);
  return this;
}

代码示例来源:origin: lkorth/httpebble-android

/**
 * Start part of a multipart
 *
 * @return this request
 * @throws IOException
 */
protected HttpRequest startPart() throws IOException {
  if (!multipart) {
    multipart = true;
    contentType(CONTENT_TYPE_MULTIPART).openOutput();
    output.write("--" + BOUNDARY + CRLF);
  } else
    output.write(CRLF + "--" + BOUNDARY + CRLF);
  return this;
}

代码示例来源:origin: com.github.kevinsawicki/http-request

final boolean first = !form;
if (first) {
 contentType(CONTENT_TYPE_FORM, charset);
 form = true;

代码示例来源:origin: MrPowerGamerBR/TemmieWebhook

public void run() {
    String strResponse = HttpRequest.post(url)
        .acceptJson()
        .contentType("application/json")
        .header("User-Agent", "Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11") // Why? Because discordapp.com blocks the default User Agent
        .send(gson.toJson(dm))
        .body();
    if (!strResponse.isEmpty()) {
      Response response = gson.fromJson(strResponse, Response.class);
      try {
        if (response.getMessage().equals("You are being rate limited.")) {
          // If we are rate limited, let's wait a few seconds before sending
          // the message again.
          try {
            // TODO: Should we really block the main thread just to send the message?
            // Blocking the main thread isn't a good idea... at all...
            Thread.sleep(response.getRetryAfter());
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
          sendMessage(dm);
        } else {
          throw new WebhookException(response.getMessage());
        }
      } catch (Exception e) {
        throw new WebhookException(strResponse);
      }
    }
  }
};

代码示例来源:origin: no.cantara.base/Hystrix-BaseCommands

request.contentType(HttpSender.APPLICATION_FORM_URLENCODED);
request.form(getFormParameters());

代码示例来源:origin: no.cantara.base/Hystrix-BaseCommands

request.contentType(HttpSender.APPLICATION_FORM_URLENCODED);
request.form(getFormParameters());

代码示例来源:origin: no.cantara.base/Hystrix-BaseCommands

request.contentType(HttpSender.APPLICATION_FORM_URLENCODED);
request.form(getFormParameters());

相关文章

微信公众号

最新文章

更多

HttpRequest类方法