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

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

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

HttpRequest.send介绍

[英]Write contents of file to request body
[中]将文件内容写入请求正文

代码示例

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

/**
 * Write a multipart header to the response body
 *
 * @param name
 * @param value
 * @return this request
 * @throws HttpRequestException
 */
public HttpRequest partHeader(final String name, final String value)
  throws HttpRequestException {
 return send(name).send(": ").send(value).send(CRLF);
}

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

/**
 * Write a multipart header to the response body
 *
 * @param name
 * @param value
 * @return this request
 * @throws HttpRequestException
 */
public HttpRequest partHeader(final String name, final String value)
    throws HttpRequestException {
  return send(name).send(": ").send(value).send(CRLF);
}

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

/**
 * Write a multipart header to the response body
 *
 * @param name
 * @param value
 * @return this request
 * @throws HttpRequestException
 */
public HttpRequest partHeader(final String name, final String value)
    throws HttpRequestException {
  return send(name).send(": ").send(value).send(CRLF);
}

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

/**
 * Write a multipart header to the response body
 *
 * @param name
 * @param value
 * @return this request
 * @throws HttpRequestException
 */
public HttpRequest partHeader(final String name, final String value)
  throws HttpRequestException {
 return send(name).send(": ").send(value).send(CRLF);
}

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

/**
 * Write byte array to request body
 *
 * @param input
 * @return this request
 * @throws HttpRequestException
 */
public HttpRequest send(final byte[] input) throws HttpRequestException {
 return send(new ByteArrayInputStream(input));
}

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

/**
 * Write byte array to request body
 *
 * @param input
 * @return this request
 * @throws HttpRequestException
 */
public HttpRequest send(final byte[] input) throws HttpRequestException {
  return send(new ByteArrayInputStream(input));
}

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

/**
 * Write byte array to request body
 *
 * @param input
 * @return this request
 * @throws HttpRequestException
 */
public HttpRequest send(final byte[] input) throws HttpRequestException {
 if (input != null)
  incrementTotalSize(input.length);
 return send(new ByteArrayInputStream(input));
}

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

/**
 * Write byte array to request body
 *
 * @param input
 * @return this request
 * @throws HttpRequestException
 */
public HttpRequest send(final byte[] input) throws HttpRequestException {
  if (input != null)
    incrementTotalSize(input.length);
  return send(new ByteArrayInputStream(input));
}

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

/**
 * Write contents of file to request body
 *
 * @param input
 * @return this request
 * @throws HttpRequestException
 */
public HttpRequest send(final File input) throws HttpRequestException {
 final InputStream stream;
 try {
  stream = new BufferedInputStream(new FileInputStream(input));
 } catch (FileNotFoundException e) {
  throw new HttpRequestException(e);
 }
 return send(stream);
}

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

/**
 * Write contents of file to request body
 *
 * @param input
 * @return this request
 * @throws HttpRequestException
 */
public HttpRequest send(final File input) throws HttpRequestException {
  final InputStream stream;
  try {
    stream = new BufferedInputStream(new FileInputStream(input));
  } catch (FileNotFoundException e) {
    throw new HttpRequestException(e);
  }
  return send(stream);
}

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

/**
 * Write contents of file to request body
 *
 * @param input
 * @return this request
 * @throws HttpRequestException
 */
public HttpRequest send(final File input) throws HttpRequestException {
 final InputStream stream;
 try {
  stream = new BufferedInputStream(new FileInputStream(input));
  incrementTotalSize(input.length());
 } catch (FileNotFoundException e) {
  throw new HttpRequestException(e);
 }
 return send(stream);
}

代码示例来源:origin: SINTEF-9012/cloudml

/**
 * This method sends a request to attach an observer to a specific metric
 * @param callback the address on which the observer is running
 *
 * @param metric the requested metric
 */
public void attachObserver(String callback, String metric) {
  String url = address + "/" + version + "/metrics/" + metric + "/observers";
  try {
  HttpRequest.post(url).send(callback).code();
      journal.log(Level.INFO, "Observer attached");
  } catch (Exception e) {
    journal.log(Level.INFO, "Connection to the monitoring manager refused");
  }
}

代码示例来源:origin: SINTEF-9012/cloudml

/**
 * This method sends a request to upload a monitoring rule to the monitoring manager.
 @param rule is the monitoring rule to be uploaded
 @return the response of the monitoring manager
 */
public String addMonitoringRule(String rule){
  String url = address + "/" + version + "/monitoring-rules";
  String response = null;
  try {
    response = HttpRequest.post(url).send(rule).body();
  } catch (Exception e) {
    journal.log(Level.INFO, "Connection to the monitoring manager refused");
  }
  return response;
}

代码示例来源:origin: restx/restx

/**
 * Share the stats to share URL. Must not be called if sharing is disabled.
 * shareEnabled check is not done to avoid double checking.
 */
private void shareStats() {
  try {
    int code = HttpRequest.post(shareURL)
        .connectTimeout(5000)
        .readTimeout(5000)
        .send(objectMapper.writer().writeValueAsString(stats).getBytes(Charsets.UTF_8))
        .code();
    if (code >= 400) {
      logger.info("sharing stats on {} failed. Response code: {}", shareURL, code);
    }
  } catch (Exception e) {
    logger.info("sharing stats on {} failed. Exception: {}", shareURL, e.getMessage());
  }
}

代码示例来源: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: 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: com.restfuse/com.eclipsesource.restfuse

public Response put() {
 HttpRequest request = HttpRequest.put( url );
 addContentType( request );
 addHeaders( request );
 addAuthentication( request );
 request.send( content );
 sendRequest( request );
 return new ResponseImpl( request );
}

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

public Response post() {
 HttpRequest request = HttpRequest.post( url );
 addContentType( request );
 addHeaders( request );
 addAuthentication( request );
 request.send( content );
 sendRequest( request );
 return new ResponseImpl( request );
}

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

private String doPost() {
  HttpRequest post = HttpRequest.post(url, params, encode)
      .headers(headers)
      .connectTimeout(connectTimeout)
      .readTimeout(readTimeout)
      .acceptGzipEncoding()
      .uncompress(true);
  setOptionalHeaders(post);
  if (!Strings.isNullOrEmpty(body)){
    post.send(body);
  }
  if (ssl){
    trustHttps(post);
  }
  return post.body();
}

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

private String doPost() {
  HttpRequest post = HttpRequest.post(url, params, encode)
      .headers(headers)
      .connectTimeout(connectTimeout)
      .readTimeout(readTimeout)
      .acceptGzipEncoding()
      .uncompress(true);
  setOptionalHeaders(post);
  if (!Strings.isNullOrEmpty(body)){
    post.send(body);
  }
  if (ssl){
    trustHttps(post);
  }
  return post.body();
}

相关文章

微信公众号

最新文章

更多

HttpRequest类方法