/** * Add a header line without any validation. Only appropriate for headers from the remote peer * or cache. */ Builder addLenient(String line) { int index = line.indexOf(":", 1); if (index != -1) { return addLenient(line.substring(0, index), line.substring(index + 1)); } else if (line.startsWith(":")) { // Work around empty header names and header names that start with a // colon (created by old broken SPDY versions of the response cache). return addLenient("", line.substring(1)); // Empty header name. } else { return addLenient("", line); // No header name. } }
/** * Add a header line without any validation. Only appropriate for headers from the remote peer * or cache. */ Builder addLenient(String line) { int index = line.indexOf(":", 1); if (index != -1) { return addLenient(line.substring(0, index), line.substring(index + 1)); } else if (line.startsWith(":")) { // Work around empty header names and header names that start with a // colon (created by old broken SPDY versions of the response cache). return addLenient("", line.substring(1)); // Empty header name. } else { return addLenient("", line); // No header name. } }
int varyRequestHeaderLineCount = readInt(source); for (int i = 0; i < varyRequestHeaderLineCount; i++) { varyHeadersBuilder.addLenient(source.readUtf8LineStrict()); int responseHeaderLineCount = readInt(source); for (int i = 0; i < responseHeaderLineCount; i++) { responseHeadersBuilder.addLenient(source.readUtf8LineStrict());
/** * Set a field with the specified value. If the field is not found, it is added. If the field is * found, the existing values are replaced. */ public Builder set(String name, String value) { checkNameAndValue(name, value); removeAll(name); addLenient(name, value); return this; }
/** Add a field with the specified value. */ public Builder add(String name, String value) { checkNameAndValue(name, value); return addLenient(name, value); }
/** * Set a field with the specified value. If the field is not found, it is * added. If the field is found, the existing values are replaced. */ public Builder set(String name, String value) { checkNameAndValue(name, value); removeAll(name); addLenient(name, value); return this; }
public static void setRequestHeaderLenient(@NonNull Request.Builder builder, @NonNull String name, @NonNull String value) { builder.headers.removeAll(name); builder.headers.addLenient(name, value); }
int varyRequestHeaderLineCount = readInt(source); for (int i = 0; i < varyRequestHeaderLineCount; i++) { varyHeadersBuilder.addLenient(source.readUtf8LineStrict()); int responseHeaderLineCount = readInt(source); for (int i = 0; i < responseHeaderLineCount; i++) { responseHeadersBuilder.addLenient(source.readUtf8LineStrict());
@Override public void addLenient(Headers.Builder builder, String name, String value) { builder.addLenient(name, value); }
@Override public void addLenient(Headers.Builder builder, String line) { builder.addLenient(line); }
/** * Set a field with the specified value. If the field is not found, it is added. If the field is * found, the existing values are replaced. */ public Builder set(String name, String value) { checkName(name); checkValue(value, name); removeAll(name); addLenient(name, value); return this; }
/** * Add a header with the specified name and value. Does validation of header names, allowing * non-ASCII values. */ public Builder addUnsafeNonAscii(String name, String value) { checkName(name); return addLenient(name, value); }
/** * Adds all headers from an existing collection. */ public Builder addAll(Headers headers) { for (int i = 0, size = headers.size(); i < size; i++) { addLenient(headers.name(i), headers.value(i)); } return this; }
/** * Add a header with the specified name and value. Does validation of header names and values. */ public Builder add(String name, String value) { checkName(name); checkValue(value, name); return addLenient(name, value); }
@Override public void addLenient(Headers.Builder builder, String line) { builder.addLenient(line); }
@Override public void addLenient(Headers.Builder builder, String name, String value) { builder.addLenient(name, value); }
/** * Set a field with the specified value. If the field is not found, it is added. If the field is * found, the existing values are replaced. */ public Builder set(String name, String value) { checkName(name); checkValue(value, name); removeAll(name); addLenient(name, value); return this; }
/** * Add a header with the specified name and value. Does validation of header names, allowing * non-ASCII values. */ public Builder addUnsafeNonAscii(String name, String value) { checkName(name); return addLenient(name, value); }
/** * Add a header with the specified name and value. Does validation of header names and values. */ public Builder add(String name, String value) { checkName(name); checkValue(value, name); return addLenient(name, value); }
/** * Adds all headers from an existing collection. */ public Builder addAll(Headers headers) { for (int i = 0, size = headers.size(); i < size; i++) { addLenient(headers.name(i), headers.value(i)); } return this; }