public ApacheFromServer(final URI originalUri, final HttpResponse response) { this.uri = originalUri; this.response = response; this.entity = response.getEntity(); if (entity != null) { try { this.inputStream = entity.getContent(); } catch (IOException e) { throw new RuntimeException("Could not get input stream from apache http client", e); } } else { this.inputStream = null; } this.headers = new ArrayList<>(response.getAllHeaders().length); for (org.apache.http.Header header : response.getAllHeaders()) { headers.add(Header.keyValue(header.getName(), header.getValue())); } addCookieStore(uri, headers); }
public ApacheFromServer(final URI originalUri, final HttpResponse response) { this.uri = originalUri; this.response = response; this.entity = response.getEntity(); if (entity != null) { try { this.inputStream = entity.getContent(); } catch (IOException e) { throw new RuntimeException("Could not get input stream from apache http client", e); } } else { this.inputStream = null; } this.headers = new ArrayList<>(response.getAllHeaders().length); for (org.apache.http.Header header : response.getAllHeaders()) { headers.add(Header.keyValue(header.getName(), header.getValue())); } addCookieStore(uri, headers); }
private List<Header<?>> populateHeaders() { final List<Header<?>> ret = new ArrayList<>(); for (int i = 0; i < Integer.MAX_VALUE; ++i) { final String key = clean(connection.getHeaderFieldKey(i)); final String value = clean(connection.getHeaderField(i)); if (key == null && value == null) { break; } if (key != null && value != null) { ret.add(Header.keyValue(key.trim(), value.trim())); } } return Collections.unmodifiableList(ret); }
/** * Creates a `Header` from a full header string. The string format is colon-delimited as `KEY:VALUE`. * * [source,groovy] * ---- * Header header = Header.full('Content-Type:text/plain') * assert header.key == 'Content-Type' * assert header.value == 'text/plain' * ---- * * @param raw the full header string * @return the `Header` representing the given header string */ public static Header<?> full(final String raw) { return keyValue(key(raw), value(raw)); }
/** * Creates a `Header` from a full header string. The string format is colon-delimited as `KEY:VALUE`. * * [source,groovy] * ---- * Header header = Header.full('Content-Type:text/plain') * assert header.key == 'Content-Type' * assert header.value == 'text/plain' * ---- * * @param raw the full header string * @return the `Header` representing the given header string */ public static Header<?> full(final String raw) { return keyValue(key(raw), value(raw)); }
/** * Creates a `Header` from a full header string. The string format is colon-delimited as `KEY:VALUE`. * * [source,groovy] * ---- * Header header = Header.full('Content-Type:text/plain') * assert header.key == 'Content-Type' * assert header.value == 'text/plain' * ---- * * @param raw the full header string * @return the `Header` representing the given header string */ public static Header<?> full(final String raw) { return keyValue(key(raw), value(raw)); }
private List<Header<?>> populateHeaders() { final List<Header<?>> ret = new ArrayList<>(); for (int i = 0; i < Integer.MAX_VALUE; ++i) { final String key = clean(connection.getHeaderFieldKey(i)); final String value = clean(connection.getHeaderField(i)); if (key == null && value == null) { break; } if (key != null && value != null) { ret.add(Header.keyValue(key.trim(), value.trim())); } } return Collections.unmodifiableList(ret); }
private List<Header<?>> populateHeaders() { final List<Header<?>> ret = new ArrayList<>(); for (int i = 0; i < Integer.MAX_VALUE; ++i) { final String key = clean(connection.getHeaderFieldKey(i)); final String value = clean(connection.getHeaderField(i)); if (key == null && value == null) { break; } if (key != null && value != null) { ret.add(Header.keyValue(key.trim(), value.trim())); } } return Collections.unmodifiableList(ret); }
private List<Header<?>> populateHeaders() { final Headers headers = response.headers(); List<Header<?>> ret = new ArrayList<>(); for (String name : headers.names()) { List<String> values = headers.values(name); for (String value : values) { ret.add(keyValue(name, value)); } } return ret; }