public boolean isAjaxRequest() { return HttpHeaderConstants.XML_HTTP_REQUEST.equalsIgnoreCase(headers.get(HttpHeaderConstants.X_REQUESTED_WITH)); }
@Override public List<String> getAll(String name) { return headers.getAll(name); }
@Override public MultiValueMap<String, String> asMultiValueMap() { return headers.asMultiValueMap(); }
@Override @Nullable public Date getDate(CharSequence name) { return headers.getDate(name); }
@Override public boolean contains(String name) { return headers.contains(name); }
@Override public Set<String> getNames() { return headers.getNames(); }
@Override public void lastModified(Instant lastModified, Runnable runnable) { Instant ifModifiedSince = requestConstants.request.getHeaders().getInstant(IF_MODIFIED_SINCE); if (ifModifiedSince != null) { // Normalise to second resolution ifModifiedSince = Instant.ofEpochSecond(ifModifiedSince.getEpochSecond()); lastModified = Instant.ofEpochSecond(lastModified.getEpochSecond()); if (!lastModified.isAfter(ifModifiedSince)) { requestConstants.response.status(Status.NOT_MODIFIED).send(); return; } } requestConstants.response.getHeaders().setDate(HttpHeaderConstants.LAST_MODIFIED, lastModified); runnable.run(); }
@Override @Nullable public Date getDate(String name) { return headers.getDate(name); }
@Override public boolean contains(CharSequence name) { return headers.contains(name); }
private String determineScheme(Request request) { Headers headers = request.getHeaders(); String forwardedSsl = headers.get(X_FORWARDED_SSL.toString()); String forwardedProto = headers.get(X_FORWARDED_PROTO.toString()); if (ON.toString().equalsIgnoreCase(forwardedSsl)) { return HTTPS_SCHEME; } return forwardedProto != null ? forwardedProto : defaultScheme; } }
@Override public List<String> getAll(CharSequence name) { return headers.getAll(name); }
/** * Returns the header value as an instant with the specified header name. * <p> * If there is more than one header value for the specified header name, the first value is returned. * * @param name the case insensitive name of the header to get retrieve the first value of * @return the header value as an instant or {@code null} if there is no such header or the header value is not a valid date format * @since 1.4 */ @Nullable default Instant getInstant(CharSequence name) { Date date = getDate(name); return date == null ? null : Instant.ofEpochMilli(date.getTime()); }
@Override public MutableHeaders copy(Headers headers) { this.wrapped.copy(headers); if (headers.contains(HttpHeaderConstants.CONTENT_TYPE)) { contentTypeSet = true; } return this; }
public Set<Cookie> getCookies() { if (cookies == null) { String header = headers.get(HttpHeaderNames.COOKIE); if (header == null || header.length() == 0) { cookies = Collections.emptySet(); } else { cookies = ServerCookieDecoder.STRICT.decode(header); } } return cookies; }
@Override public boolean isChunkedTransfer() { return Iterables.any(headers.getAll(HttpHeaderNames.TRANSFER_ENCODING), HttpHeaderValues.CHUNKED::contentEqualsIgnoreCase); }
@Nullable @Override public String get(CharSequence name) { return headers.get(name); }
@Override public boolean isExpectsContinue() { return Iterables.any(headers.getAll(HttpHeaderNames.EXPECT), HttpHeaderValues.CONTINUE::contentEqualsIgnoreCase); }
@Override @Nullable public String get(String name) { return headers.get(name); }
private void extractCookies(ReceivedResponse response) { List<String> cookieHeaders = response.getHeaders().getAll("Set-Cookie"); for (String cookieHeader : cookieHeaders) { Cookie decodedCookie = ClientCookieDecoder.STRICT.decode(cookieHeader);
public boolean hasValidHeader(Headers headers, String token) { String submittedHeader = headers.get(config.getHeaderName()); return token.equals(submittedHeader); }