/** * Sets the etag. * * @param etag the etag. * @return this */ public Builder etag(final String etag) { if (etag == null) { mHeaders.removeAll(ETAG); } else { mHeaders.set(ETAG, etag); } return this; }
private static void appendHeaders(Request.Builder builder, Map<String, String> headers) { Headers.Builder headerBuilder = new Headers.Builder(); if (headers == null || headers.isEmpty()) return; for (String key : headers.keySet()) { headerBuilder.add(key, headers.get(key)); } builder.headers(headerBuilder.build()); }
protected void appendHeaders() { Headers.Builder headerBuilder = new Headers.Builder(); if (headers == null || headers.isEmpty()) return; for (String key : headers.keySet()) { headerBuilder.add(key, headers.get(key)); } builder.headers(headerBuilder.build()); }
public PostRequest addHeader(String key, String value) { if (headers == null) { headers = new Headers.Builder(); } headers.add(key, value); return this; }
public Request create() { builder.url(url); builder.tag(tag); if (headers != null) { builder.headers(headers.build()); } builder.post(requestBody); return builder.build(); }
/** * Removes all values for the specified header name. * * @param name the header name. * @return this */ public Builder removeHeader(final String name) { mHeaders.removeAll(name); return this; }
/** * Adds the value for the header with the specified name. It doesn't replaces any previous value * set for the same header name. * * @param name the header name. * @param value the header value. * @return this */ public Builder addHeader(final String name, final String value) { mHeaders.add(name, value); return this; }
/** * Sets the value for the header with the specified name. It replaces any previous value set for * the same header name. * * @param name the header name. * @param value the header value. * @return this */ public Builder header(final String name, final String value) { mHeaders.set(name, value); return this; }
/** * Sets the location header. * * @param path the location path. * @return this */ public Builder location(final String path) { mHeaders.set(LOCATION, path); return this; }
/** * Sets the location header. * * @param url the location. * @return this */ public Builder location(final HttpUrl url) { mHeaders.set(LOCATION, url.toString()); return this; }
/** * Sets the strict transport security header, with the specified max-age. * * @param secs the max-age in seconds. * @return this */ public Builder hsts(final long secs) { mHeaders.set(STRICT_TRANSPORT_SECURITY, "max-age=" + secs); return this; }
@Override protected Headers.Builder headersBuilder() { Headers.Builder builder = super.headersBuilder(); builder.add("Host", HOST); return builder; }
/** * Sets the cache control header to private. * * @return this */ public Builder priv() { mHeaders.add(CACHE_CONTROL, "private"); return this; }
/** * Sets the cache control header to no-store and removes the etag. * * @return this */ public Builder noStore() { mHeaders.removeAll(ETAG).set(CACHE_CONTROL, "no-store"); return this; }
/** * Sets the etag (optional) and the cache control header to no-cache. * * @param etag the etag (optional). * @return this */ public Builder noCache(final String etag) { if (etag != null) mHeaders.set(ETAG, etag); mHeaders.set(CACHE_CONTROL, "no-cache"); return this; }
/** * Sets the content length header to the specified length. * * @param length the content length. * @return this */ public Builder contentLength(final long length) { mHeaders.set(CONTENT_LENGTH, String.valueOf(length)); return this; }
/** * Sets the content type header to the specified media type. * * @param contentType the media type. * @return this */ public Builder contentType(final MediaType contentType) { mHeaders.set(CONTENT_TYPE, contentType.toString()); return this; }
/** * Sets the cache control max-age value. * * @param secs the max-age value in seconds. * @return this */ public Builder maxAge(final long secs) { mHeaders.add(CACHE_CONTROL, "max-age=" + secs); return this; }