private Headers buildHeaders() { return Headers.of(headers); }
public ApiRequest(String url, Class<? extends R> responseClass) { this.url = url; this.responseClass = responseClass; this.parameters = new HashMap<>(); this.headers = Headers.of("User-Agent", Constant.USER_AGENT, "Content-Type", this.contentType); }
public static Part createFormData(String name, @Nullable String filename, RequestBody body) { if (name == null) { throw new NullPointerException("name == null"); } StringBuilder disposition = new StringBuilder("form-data; name="); appendQuotedString(disposition, name); if (filename != null) { disposition.append("; filename="); appendQuotedString(disposition, filename); } return create(Headers.of("Content-Disposition", disposition.toString()), body); }
@Override void apply(RequestBuilder builder, @Nullable Map<String, T> value) throws IOException { if (value == null) { throw Utils.parameterError(method, p, "Part map was null."); } for (Map.Entry<String, T> entry : value.entrySet()) { String entryKey = entry.getKey(); if (entryKey == null) { throw Utils.parameterError(method, p, "Part map contained null key."); } T entryValue = entry.getValue(); if (entryValue == null) { throw Utils.parameterError(method, p, "Part map contained null value for key '" + entryKey + "'."); } Headers headers = Headers.of( "Content-Disposition", "form-data; name=\"" + entryKey + "\"", "Content-Transfer-Encoding", transferEncoding); builder.addPart(headers, valueConverter.convert(entryValue)); } } }
@Override void apply(RequestBuilder builder, @Nullable Map<String, T> value) throws IOException { if (value == null) { throw new IllegalArgumentException("Part map was null."); } for (Map.Entry<String, T> entry : value.entrySet()) { String entryKey = entry.getKey(); if (entryKey == null) { throw new IllegalArgumentException("Part map contained null key."); } T entryValue = entry.getValue(); if (entryValue == null) { throw new IllegalArgumentException( "Part map contained null value for key '" + entryKey + "'."); } Headers headers = Headers.of( "Content-Disposition", "form-data; name=\"" + entryKey + "\"", "Content-Transfer-Encoding", transferEncoding); builder.addPart(headers, valueConverter.convert(entryValue)); } } }
mediaType = MediaType.parse(stringBody.contentType); builder.addPart(Headers.of("Content-Disposition", "form-data; name=\"" + entry.getKey() + "\""), RequestBody.create(mediaType, stringBody.value)); builder.addPart(Headers.of("Content-Disposition", "form-data; name=\"" + entry.getKey() + "\"; filename=\"" + fileName + "\""), requestBody);
.headers(Headers.of(headers));
builder.setType(MultipartBody.FORM); builder.addPart( Headers.of("Content-Disposition", "form-data; name=\"sfile\"; filename=\"a.jpg\""), RequestBody.create(MEDIA_TYPE_JPEG, image) ); if (uss) { builder.addPart( Headers.of("Content-Disposition", "form-data; name=\"fs_similar\""), RequestBody.create(null, "on") ); Headers.of("Content-Disposition", "form-data; name=\"fs_covers\""), RequestBody.create(null, "on") ); Headers.of("Content-Disposition", "form-data; name=\"fs_exp\""), RequestBody.create(null, "on") ); Headers.of("Content-Disposition", "form-data; name=\"f_sfile\""), RequestBody.create(null, "File Search") );
Headers.of("Content-Disposition", "form-data; name=\"" + partName + "\"", "Content-Transfer-Encoding", part.encoding());
Headers.of("Content-Disposition", "form-data; name=\"" + partName + "\"", "Content-Transfer-Encoding", part.encoding());
/** * Set the default headers to be used on every HTTP request. * * @param headers name value pairs of headers */ public void setDefaultHeaders(final Map<String, String> headers) { if (headers == null) { defaultHeaders = null; } else { defaultHeaders = Headers.of(headers); } }
RecordedResponse(int code, Map<String, String> headers, byte[] body) { super(Headers.of(headers), body); this.code = code; this.protocol = Protocol.HTTP_1_1; }
RecordedResponse(int code, Map<String, String> headers, byte[] body) { super(Headers.of(headers), body); this.code = code; this.protocol = Protocol.HTTP_1_1; }
public RecordedResponse(int code, Map<String, String> headers, byte[] body) { super(Headers.of(headers), body); this.code = code; this.protocol = Protocol.HTTP_1_1; }
RecordedRequest(String method, String url, Map<String, String> headers, byte[] body) { super(Headers.of(headers), body); this.method = method; this.url = HttpUrl.parse(url); }
public RecordedRequest(String method, String url, Map<String, String> headers, byte[] body) { super(Headers.of(headers), body); this.method = method; this.url = HttpUrl.parse(url); }
private void addParams(MultipartBody.Builder builder) { if (params != null && !params.isEmpty()) { params.forEach((k,v)->{ builder.addPart(Headers.of("Content-Disposition", "form-data; name=\"" + k + "\""), RequestBody.create(null,v)); }); } } //
public static Part createFormData(String name, @Nullable String filename, RequestBody body) { if (name == null) { throw new NullPointerException("name == null"); } StringBuilder disposition = new StringBuilder("form-data; name="); appendQuotedString(disposition, name); if (filename != null) { disposition.append("; filename="); appendQuotedString(disposition, filename); } return create(Headers.of("Content-Disposition", disposition.toString()), body); }
public static Part createFormData(String name, String filename, RequestBody body) { if (name == null) { throw new NullPointerException("name == null"); } StringBuilder disposition = new StringBuilder("form-data; name="); appendQuotedString(disposition, name); if (filename != null) { disposition.append("; filename="); appendQuotedString(disposition, filename); } return create(Headers.of("Content-Disposition", disposition.toString()), body); }
private Observable<Response<SuccessResponse>> getLoginSuccessResponse() { SuccessResponse successResponse = new SuccessResponse(); successResponse.stat = STATUS_OK; successResponse.result = true; Response<SuccessResponse> response = Response.success(successResponse, Headers.of("Set-Cookie", "pwg_id=" + COOKIE_PWG_ID)); return Observable.just(response); }