Esempio n. 1
0
  /**
   * Builds request content string from request and body.
   *
   * @param request
   * @param body
   * @return
   */
  private String getRequestContent(HttpRequest request, String body) {
    StringBuilder builder = new StringBuilder();

    builder.append(request.getMethod());
    builder.append(" ");
    builder.append(request.getURI());
    builder.append(NEWLINE);

    appendHeaders(request.getHeaders(), builder);

    builder.append(NEWLINE);
    builder.append(body);

    return builder.toString();
  }
 private void addGeoQueryParams(UriComponentsBuilder builder, GeoQuery geoQuery) {
   if (geoQuery != null) {
     StringBuilder georel = new StringBuilder(geoQuery.getRelation().name());
     if (geoQuery.getRelation() == GeoQuery.Relation.near) {
       georel.append(';').append(geoQuery.getModifier());
       georel.append(':').append(geoQuery.getDistance());
     }
     builder.queryParam("georel", georel.toString());
     builder.queryParam("geometry", geoQuery.getGeometry());
     builder.queryParam(
         "coords",
         geoQuery
             .getCoordinates()
             .stream()
             .map(Coordinate::toString)
             .collect(Collectors.joining(";")));
   }
 }
Esempio n. 3
0
  /**
   * Builds response content string from response object.
   *
   * @param response
   * @return
   * @throws IOException
   */
  private String getResponseContent(CachingClientHttpResponseWrapper response) throws IOException {
    if (response != null) {
      StringBuilder builder = new StringBuilder();

      builder.append("HTTP/1.1 ");
      builder.append(response.getStatusCode());
      builder.append(" ");
      builder.append(response.getStatusText());
      builder.append(NEWLINE);

      appendHeaders(response.getHeaders(), builder);

      builder.append(NEWLINE);
      builder.append(response.getBodyContent());

      return builder.toString();
    } else {
      return "";
    }
  }