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

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

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

HttpRequest.body介绍

[英]Get response as String using character set returned from #charset()
[中]使用从#charset()返回的字符集获取作为字符串的响应

代码示例

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

/**
 * Get the response body as a {@link String} and set it as the value of the
 * given reference.
 *
 * @param output
 * @return this request
 * @throws HttpRequestException
 */
public HttpRequest body(final AtomicReference<String> output) throws HttpRequestException {
 output.set(body());
 return this;
}

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

/**
 * Get the response body as a {@link String} and set it as the value of the
 * given reference.
 *
 * @param output
 * @return this request
 * @throws HttpRequestException
 */
public HttpRequest body(final AtomicReference<String> output) throws HttpRequestException {
  output.set(body());
  return this;
}

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

/**
 * Get the response body as a {@link String} and set it as the value of the
 * given reference.
 *
 * @param output
 * @param charset
 * @return this request
 * @throws HttpRequestException
 */
public HttpRequest body(final AtomicReference<String> output, final String charset) throws HttpRequestException {
 output.set(body(charset));
 return this;
}

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

/**
 * Get the response body as a {@link String} and set it as the value of the
 * given reference.
 *
 * @param output
 * @param charset
 * @return this request
 * @throws HttpRequestException
 */
public HttpRequest body(final AtomicReference<String> output, final String charset) throws HttpRequestException {
  output.set(body(charset));
  return this;
}

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

/**
 * Get response as {@link String} using character set returned from
 * {@link #charset()}
 *
 * @return string
 * @throws HttpRequestException
 */
public String body() throws HttpRequestException {
 return body(charset());
}

代码示例来源:origin: stackoverflow.com

File latest = new File("/data/cache.json");
HttpRequest request = HttpRequest.get("http://google.com");
//Copy response to file
request.body(latest);
//Store eTag of response
String eTag = request.eTag();
//Later on check if changes exist
boolean unchanged = HttpRequest.get("http://google.com")
                .ifNoneMatch(eTag)
                .notModified();

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

/**
 * Get response as {@link String} using character set returned from
 * {@link #charset()}
 *
 * @return string
 * @throws HttpRequestException
 */
public String body() throws HttpRequestException {
  return body(charset());
}

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

/**
 * Get response as {@link String} using character set returned from
 * {@link #charset()}
 *
 * @return string
 * @throws HttpRequestException
 */
public String body() throws HttpRequestException {
  return body(charset());
}

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

/**
 * Get response as {@link String} using character set returned from
 * {@link #charset()}
 *
 * @return string
 * @throws HttpRequestException
 */
public String body() throws HttpRequestException {
 return body(charset());
}

代码示例来源:origin: com.codeslap/github-jobs-java-api

public User getUser(String username) {
    String url = String.format(ApiConstants.API_URL, String.format(ApiConstants.GET_USER, username));
    try {
      String response = HttpRequest.get(url).body();
      // convert json to object
      Gson gson = new Gson();
      return gson.fromJson(response, User.class);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
}

代码示例来源:origin: stackoverflow.com

File latest = new File("/data/cache.json");
HttpRequest request = HttpRequest.get("http://google.com");
//Copy response to file
request.body(latest);
//Store eTag of response
String eTag = request.eTag();

//Later you can check if changes exist
boolean unchanged = HttpRequest.get("http://google.com")
              .ifNoneMatch(eTag)
              .notModified();

代码示例来源:origin: stackoverflow.com

HttpRequest request = HttpRequest.get("http://google.com");
String body = request.body();
int code = request.code();

代码示例来源:origin: k55k32/cms-admin-end

public static String getLocation(String ip) throws JsonProcessingException, IOException {
    String result = HttpRequest.get(api, ImmutableMap.of("ip", ip, "datatype", "jsonp", "token", token), false).body();
    ObjectMapper om = new ObjectMapper();
    JsonNode node = om.readTree(result);
    ArrayNode data = (ArrayNode) node.get("data");
    return data.get(0).asText() + data.get(1).asText() + data.get(2).asText() + data.get(3).asText();
  }
}

代码示例来源:origin: com.codeslap/github-jobs-java-api

public static boolean subscribe(String email, String description, String location, boolean fullTime) {
  HashMap<String, String> parameters = new HashMap<String, String>();
  parameters.put(SUBSCRIPTION_EMAIL_PARAM, email);
  parameters.put(SUBSCRIPTION_DESCRIPTION_PARAM, description);
  parameters.put(SUBSCRIPTION_LOCATION_PARAM, location);
  parameters.put(SUBSCRIPTION_FULL_TIME_PARAM, String.valueOf(fullTime));
  String response = HttpRequest.post(ApiConstants.EMAIL_SUBSCRIPTION_URL)
      .part(SUBSCRIPTION_EMAIL_PARAM, email)
      .part(SUBSCRIPTION_DESCRIPTION_PARAM, description)
      .part(SUBSCRIPTION_LOCATION_PARAM, location)
      .part(SUBSCRIPTION_FULL_TIME_PARAM, String.valueOf(fullTime))
      .body();
  return SUBSCRIPTION_OK_PARAM.equals(response);
}

代码示例来源:origin: stackoverflow.com

String httpQuery = new QueryBuilder().setLocalityFilter(query).build();

try {
      HttpRequest request =  HttpRequest.get(httpQuery);
      if (request.ok()) {
        String response = request.body();
        restaurantArrayList = JsonParser.parseHTTPResponse(response);
      }
      return restaurantArrayList;
  } catch (HttpRequest.HttpRequestException exception) {
      return null;
}

代码示例来源:origin: stackoverflow.com

HttpRequest req = HttpRequest.get("https://google.com");
req.trustAllCerts();
req.trustAllHosts(); //If you are having certificate problems
int code = req.code();
String body = req.body();
Log.d("CODE:", String.valueOf(code));
Log.d("BODY:", body);

代码示例来源: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: ihaolin/antares

private String doGet() {
  HttpRequest get = HttpRequest.get(url, params, encode)
      .headers(headers)
      .connectTimeout(connectTimeout)
      .readTimeout(readTimeout)
      .acceptGzipEncoding()
      .uncompress(true);
  if (ssl){
    trustHttps(get);
  }
  setOptionalHeaders(get);
  return get.body();
}

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

private String doGet() {
  HttpRequest get = HttpRequest.get(url, params, encode)
      .headers(headers)
      .connectTimeout(connectTimeout)
      .readTimeout(readTimeout)
      .acceptGzipEncoding()
      .uncompress(true);
  if (ssl){
    trustHttps(get);
  }
  setOptionalHeaders(get);
  return get.body();
}

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

private String doGet() {
  HttpRequest get = HttpRequest.get(url, params, encode)
      .headers(headers)
      .connectTimeout(connectTimeout)
      .readTimeout(readTimeout)
      .acceptGzipEncoding()
      .uncompress(true);
  if (ssl){
    trustHttps(get);
  }
  setOptionalHeaders(get);
  return get.body();
}

相关文章

HttpRequest类方法