/** * Returns the value of the header with the specified {@code name}. * If there is more than one header value for the specified header name, the first value is returned. * * @return the value of the header with the specified {@code name} if present */ public Optional<String> header(CharSequence name) { return headers.get(name); }
@Override public Optional<String> header(CharSequence name) { return headers.get(name); }
/** * Returns the value of the header with the specified {@code name}. * If there is more than one header value for the specified header name, the first value is returned. * * @return the value of the header with the specified {@code name} if present */ public Optional<String> header(CharSequence name) { return headers.get(name); }
@Override public Optional<String> header(CharSequence name) { return headers.get(name); }
@Override public Optional<String> header(CharSequence name) { return headers.get(name); }
/** * Decodes the "Cookie" header in this request and returns the cookies. * * @return a set of cookies */ public Set<RequestCookie> cookies() { return headers.get(COOKIE) .map(RequestCookie::decode) .orElseGet(Collections::emptySet); }
/** * Decodes the "Cookie" header in this request and returns the cookies. * * @return a set of cookies */ public Set<RequestCookie> cookies() { return headers.get(COOKIE) .map(RequestCookie::decode) .orElseGet(Collections::emptySet); }
public static boolean keepAlive(HttpHeaders headers, com.hotels.styx.api.messages.HttpVersion version) { Optional<String> connection = headers.get(CONNECTION); if (connection.isPresent()) { if (CLOSE.toString().equalsIgnoreCase(connection.get())) { return false; } if (KEEP_ALIVE.toString().equalsIgnoreCase(connection.get())) { return true; } } return version.isKeepAliveDefault(); } }
/** * Returns the value of the header with the specified {@code name}. * If there is more than one header value for the specified header name, the first value is returned. * * @return the value of the header with the specified {@code name} if present */ default Optional<String> header(CharSequence name) { return headers().get(name); }
private String xHcomPluginsHeader(LiveHttpRequest message) { return message.headers().get(X_HCOM_PLUGINS_HEADER).orElse("") .concat(" test-plugin-a") .trim(); }
/** * Returns the value of the header with the specified {@code name}. * If there is more than one header value for the specified header name, the first value is returned. * * @return the value of the header with the specified {@code name} if present */ default Optional<String> header(CharSequence name) { return headers().get(name); }
/** * Returns the value of the header with the specified {@code name}. * If there is more than one header value for the specified header name, the first value is returned. * * @return the value of the header with the specified {@code name} if present */ default Optional<String> header(CharSequence name) { return headers().get(name); }
public static boolean keepAlive(HttpHeaders headers, HttpVersion version) { Optional<String> connection = headers.get(CONNECTION); if (connection.isPresent()) { if (CLOSE.toString().equalsIgnoreCase(connection.get())) { return false; } if (KEEP_ALIVE.toString().equalsIgnoreCase(connection.get())) { return true; } } return version.isKeepAliveDefault(); } }
/** * Returns the value of the header with the specified {@code name}. * If there is more than one header value for the specified header name, the first value is returned. * * @return the value of the header with the specified {@code name} if present */ default Optional<String> header(CharSequence name) { return headers().get(name); }
public static boolean keepAlive(HttpHeaders headers, HttpVersion version) { Optional<String> connection = headers.get(CONNECTION); if (connection.isPresent()) { if (CLOSE.toString().equalsIgnoreCase(connection.get())) { return false; } if (KEEP_ALIVE.toString().equalsIgnoreCase(connection.get())) { return true; } } return version.isKeepAliveDefault(); }
private static CharSequence viaHeader(LiveHttpResponse httpMessage) { CharSequence styxViaEntry = styxViaEntry(httpMessage.version()); return httpMessage.headers().get(VIA) .map(viaHeader -> !isNullOrEmpty(viaHeader) ? viaHeader + ", " + styxViaEntry : styxViaEntry) .orElse(styxViaEntry); }
private static CharSequence viaHeader(LiveHttpRequest httpMessage) { CharSequence styxViaEntry = styxViaEntry(httpMessage.version()); return httpMessage.headers().get(VIA) .map(viaHeader -> !isNullOrEmpty(viaHeader) ? viaHeader + ", " + styxViaEntry : styxViaEntry) .orElse(styxViaEntry); }
@Test public void providesFirstHeaderValueWhenSeveralExist() { assertThat(headers.get("header2").get(), is("val2a")); }
@Test public void providesSingleHeaderValue() { assertThat(headers.get("header1").get(), is("val1")); }
@Test public void setsDateHeaders() { Instant time = ZonedDateTime.of(2015, 9, 10, 12, 2, 28, 0, UTC).toInstant(); HttpHeaders headers = new HttpHeaders.Builder() .set("foo", time) .build(); assertThat(headers.get("foo"), isValue("Thu, 10 Sep 2015 12:02:28 GMT")); } }