/** * Set a field with the specified instant. If the field is not found, it is added. If the field * is found, the existing values are replaced. */ @IgnoreJRERequirement public Builder set(String name, Instant value) { if (value == null) throw new NullPointerException("value for name " + name + " == null"); return set(name, new Date(value.toEpochMilli())); }
/** * Set a field with the specified instant. If the field is not found, it is added. If the field * is found, the existing values are replaced. */ @IgnoreJRERequirement public Builder set(String name, Instant value) { if (value == null) throw new NullPointerException("value for name " + name + " == null"); return set(name, new Date(value.toEpochMilli())); }
@Override public void setRequestProperty(String field, String newValue) { if (connected) { throw new IllegalStateException("Cannot set request property after connection is made"); } if (field == null) { throw new NullPointerException("field == null"); } if (newValue == null) { // Silently ignore null header values for backwards compatibility with older // android versions as well as with other URLConnection implementations. // // Some implementations send a malformed HTTP header when faced with // such requests, we respect the spec and ignore the header. Platform.get().log(WARN, "Ignoring header " + field + " because its value was null.", null); return; } requestHeaders.set(field, newValue); }
@Override public void setIfModifiedSince(long newValue) { super.setIfModifiedSince(newValue); if (ifModifiedSince != 0) { requestHeaders.set("If-Modified-Since", HttpDate.format(new Date(ifModifiedSince))); } else { requestHeaders.removeAll("If-Modified-Since"); } }
/** * Sets the header named {@code name} to {@code value}. If this request already has any headers * with that name, they are all replaced. */ public Builder header(String name, String value) { headers.set(name, value); return this; }
/** * Sets the header named {@code name} to {@code value}. If this request * already has any headers with that name, they are all replaced. */ public Builder header(String name, String value) { headers.set(name, value); return this; }
@Override public void setIfModifiedSince(long newValue) { super.setIfModifiedSince(newValue); if (ifModifiedSince != 0) { requestHeaders.set("If-Modified-Since", HttpDate.format(new Date(ifModifiedSince))); } else { requestHeaders.removeAll("If-Modified-Since"); } }
public OkRestTarget header(String key, String val) { OkRestTarget c = clone(); c.headers = this.headers.newBuilder().set(key, val).build(); return c; } public OkRestTarget accept(String val) {
/** * Sets the header named {@code name} to {@code value}. If this request already has any headers * with that name, they are all replaced. */ Builder header(String name, String value) { headers.set(name, value); return this; }
/** * Sets the header named {@code name} to {@code value}. If this request * already has any headers with that name, they are all replaced. */ public Builder header(String name, String value) { headers.set(name, value); return this; }
/** * Sets the header named {@code name} to {@code value}. If this request already has any headers * with that name, they are all replaced. */ Builder header(String name, String value) { headers.set(name, value); return this; }
@Override public Response intercept(Chain chain) throws IOException { Request request = chain.request(); Headers.Builder headersBuilder = request.headers().newBuilder() .set(ParseRESTCommand.HEADER_APPLICATION_ID, configuration.applicationId) .set(ParseRESTCommand.HEADER_APP_BUILD_VERSION, String.valueOf(ManifestInfo.getVersionCode())) .set(ParseRESTCommand.HEADER_APP_DISPLAY_VERSION, ManifestInfo.getVersionName()) .set(ParseRESTCommand.HEADER_OS_VERSION, Build.VERSION.RELEASE) .set(ParseRESTCommand.USER_AGENT, userAgent()); if (request.header(ParseRESTCommand.HEADER_INSTALLATION_ID) == null) { // We can do this synchronously since the caller is already on a background thread headersBuilder.set(ParseRESTCommand.HEADER_INSTALLATION_ID, installationId().get()); } // client key can be null with self-hosted Parse Server if (configuration.clientKey != null) { headersBuilder.set(ParseRESTCommand.HEADER_CLIENT_KEY, configuration.clientKey); } request = request.newBuilder() .headers(headersBuilder.build()) .build(); return chain.proceed(request); } });
public T header(String name, String value) { this.headers = this.headers.newBuilder().set(name, value).build(); return thisAsT; }
/** * Sets the header named {@code name} to {@code value}. If this request already has any headers * with that name, they are all replaced. */ public Builder header(String name, String value) { headers.set(name, value); return this; }
/** * Sets the header named {@code name} to {@code value}. If this request already has any headers * with that name, they are all replaced. */ public Builder header(String name, String value) { headers.set(name, value); return this; }
/** * Set a field with the specified date. If the field is not found, it is added. If the field is * found, the existing values are replaced. */ public Builder set(String name, Date value) { if (value == null) throw new NullPointerException("value for name " + name + " == null"); set(name, HttpDate.format(value)); return this; }
/** * Set a field with the specified date. If the field is not found, it is added. If the field is * found, the existing values are replaced. */ public Builder set(String name, Date value) { if (value == null) throw new NullPointerException("value for name " + name + " == null"); set(name, HttpDate.format(value)); return this; }
@Override public void setIfModifiedSince(long newValue) { super.setIfModifiedSince(newValue); if (ifModifiedSince != 0) { requestHeaders.set("If-Modified-Since", HttpDate.format(new Date(ifModifiedSince))); } else { requestHeaders.removeAll("If-Modified-Since"); } }
/** * Sets the header named {@code name} to {@code value}. If this request already has any headers * with that name, they are all replaced. */ public Builder header(String name, String value) { headers.set(name, value); return this; }
/** * Sets the header named {@code name} to {@code value}. If this request already has any headers * with that name, they are all replaced. */ public Builder header(String name, String value) { headers.set(name, value); return this; }