private static HttpResponse transformResponse(Response response) { int code = response.code(); String message = response.message(); BasicHttpResponse httpResponse = new BasicHttpResponse(HTTP_1_1, code, message); ResponseBody body = response.body(); InputStreamEntity entity = new InputStreamEntity(body.byteStream(), body.contentLength()); httpResponse.setEntity(entity); Headers headers = response.headers(); for (int i = 0, size = headers.size(); i < size; i++) { String name = headers.name(i); String value = headers.value(i); httpResponse.addHeader(name, value); if ("Content-Type".equalsIgnoreCase(name)) { entity.setContentType(value); } else if ("Content-Encoding".equalsIgnoreCase(name)) { entity.setContentEncoding(value); } } return httpResponse; }
if (header.getKey() != null) { Header h = new BasicHeader(header.getKey(), header.getValue().get(0)); response.addHeader(h);
if (header.getKey() != null) { Header h = new BasicHeader(header.getKey(), header.getValue().get(0)); response.addHeader(h);
if (header.getKey() != null) { Header h = new BasicHeader(header.getKey(), header.getValue().get(0)); response.addHeader(h);
final String name = responseHeaders.name(i), value = responseHeaders.value(i); if (name != null) { response.addHeader(new BasicHeader(name, value));
/** * {@inheritDoc} */ @Override public void addHeader(String name, String value) { if (response != null) { response.addHeader(name, value); } else { super.addHeader(name, value); } }
/** * {@inheritDoc} */ @Override public void addHeader(Header header) { if (response != null) { response.addHeader(header); } else { super.addHeader(header); } }
@Override public HttpResponse head() { BasicHttpResponse response = new BasicHttpResponse(this.response.getStatusLine()); Header[] allHeaders = this.response.getAllHeaders(); for (Header allHeader : allHeaders) response.addHeader(allHeader); response.setEntity(new ByteArrayEntity(new byte[]{})); return response; }
/** * Build the HTTP response using all data previously set on this builder and/or use defaults. * * @return The HTTP response */ public CloseableHttpResponse build() { BasicHttpResponse response = new BasicHttpResponse(this.protocolVersion, this.status, this.reason); for (Header h : this.headers) { response.addHeader(h.getName(), h.getValue()); } if (this.entity != null) { response.setEntity(this.entity); } return BasicCloseableHttpResponse.adapt(response); }
private static HttpResponse transformResponse(Response response) { int code = response.code(); String message = response.message(); BasicHttpResponse httpResponse = new BasicHttpResponse(HTTP_1_1, code, message); ResponseBody body = response.body(); InputStreamEntity entity = new InputStreamEntity(body.byteStream(), body.contentLength()); httpResponse.setEntity(entity); Headers headers = response.headers(); for (int i = 0, size = headers.size(); i < size; i++) { String name = headers.name(i); String value = headers.value(i); httpResponse.addHeader(name, value); if ("Content-Type".equalsIgnoreCase(name)) { entity.setContentType(value); } else if ("Content-Encoding".equalsIgnoreCase(name)) { entity.setContentEncoding(value); } } return httpResponse; }
private static HttpResponse transformResponse(Response response) { int code = response.code(); String message = response.message(); BasicHttpResponse httpResponse = new BasicHttpResponse(HTTP_1_1, code, message); ResponseBody body = response.body(); InputStreamEntity entity = new InputStreamEntity(body.byteStream(), body.contentLength()); httpResponse.setEntity(entity); Headers headers = response.headers(); for (int i = 0, size = headers.size(); i < size; i++) { String name = headers.name(i); String value = headers.value(i); httpResponse.addHeader(name, value); if ("Content-Type".equalsIgnoreCase(name)) { entity.setContentType(value); } else if ("Content-Encoding".equalsIgnoreCase(name)) { entity.setContentEncoding(value); } } return httpResponse; }
if (header.getKey() != null) { Header h = new BasicHeader(header.getKey(), header.getValue().get(0)); response.addHeader(h);
if (header.getKey() != null) { Header h = new BasicHeader(header.getKey(), header.getValue().get(0)); response.addHeader(h);
if (header.getKey() != null) { Header h = new BasicHeader(header.getKey(), header.getValue().get(0)); response.addHeader(h);
if (header.getKey() != null) { Header h = new BasicHeader(header.getKey(), header.getValue().get(0)); response.addHeader(h);
if (header.getKey() != null) { Header h = new BasicHeader(header.getKey(), header.getValue().get(0)); response.addHeader(h);
final String name = responseHeaders.name(i), value = responseHeaders.value(i); if (name != null) { response.addHeader(new BasicHeader(name, value));
if (header.getKey() != null) { Header h = new BasicHeader(header.getKey(), header.getValue().get(0)); response.addHeader(h);
private static HttpResponse transformResponse(Response response) throws IOException { int code = response.code(); String message = response.message(); BasicHttpResponse httpResponse = new BasicHttpResponse(HTTP_1_1, code, message); ResponseBody body = response.body(); InputStreamEntity entity = new InputStreamEntity(body.byteStream(), body.contentLength()); httpResponse.setEntity(entity); Headers headers = response.headers(); for (int i = 0, size = headers.size(); i < size; i++) { String name = headers.name(i); String value = headers.value(i); httpResponse.addHeader(name, value); if ("Content-Type".equalsIgnoreCase(name)) { entity.setContentType(value); } else if ("Content-Encoding".equalsIgnoreCase(name)) { entity.setContentEncoding(value); } } return httpResponse; }
evt.getHeaders().asMap().forEach((k, vs) -> vs.forEach(v -> response.addHeader(k, v)));