private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeObject(mediaType == null ? "" : mediaType.toString()); }
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeObject(contentType.toString()); }
private Request buildRequest(String hostname, int type) { Request.Builder requestBuilder = new Request.Builder().header("Accept", DNS_MESSAGE.toString()); ByteString query = DnsRecordCodec.encodeQuery(hostname, type); if (post) { requestBuilder = requestBuilder.url(url).post(RequestBody.create(DNS_MESSAGE, query)); } else { String encoded = query.base64Url().replace("=", ""); HttpUrl requestUrl = url.newBuilder().addQueryParameter("dns", encoded).build(); requestBuilder = requestBuilder.url(requestUrl); } return requestBuilder.build(); }
body = new ContentTypeOverridingRequestBody(body, contentType); } else { requestBuilder.addHeader("Content-Type", contentType.toString());
@NonNull private static String _parseParams(RequestBody body, Buffer requestBuffer) throws UnsupportedEncodingException { if (body.contentType() != null && !body.contentType().toString().contains("multipart")) { return URLDecoder.decode(requestBuffer.readUtf8(), "UTF-8"); } return "null"; }
MediaType contentType = body.contentType(); if (contentType != null) { requestBuilder.header("Content-Type", contentType.toString());
body = new ContentTypeOverridingRequestBody(body, contentType); } else { requestBuilder.addHeader("Content-Type", contentType.toString());
MediaType contentType = body.contentType(); if (contentType != null) { requestBuilder.header("Content-Type", contentType.toString());
String contentType = mediaType != null ? mediaType.toString() : ""; if (contentTypePredicate != null && !contentTypePredicate.evaluate(contentType)) { closeConnectionQuietly();
/** * Converts retrofit request to async-http-client request. * * @param request retrofit request * @return async-http-client request. */ @SneakyThrows protected org.asynchttpclient.Request createRequest(@NonNull Request request) { // create async-http-client request builder val requestBuilder = new RequestBuilder(request.method()); // request uri requestBuilder.setUrl(request.url().toString()); // set headers val headers = request.headers(); headers.names().forEach(name -> requestBuilder.setHeader(name, headers.values(name))); // set request body val body = request.body(); if (body != null && body.contentLength() > 0) { if (body.contentType() != null) { requestBuilder.setHeader(HttpHeaderNames.CONTENT_TYPE, body.contentType().toString()); } // write body to buffer val okioBuffer = new Buffer(); body.writeTo(okioBuffer); requestBuilder.setBody(okioBuffer.readByteArray()); } // customize the request builder (external customizer can change the request url for example) runConsumers(this.requestCustomizers, requestBuilder); return requestBuilder.build(); }
contentType != null ? contentType.toString() : null, response.header("Content-Encoding"), responseStream,
MediaType mediaType = responseBody.contentType(); if (mediaType != null) { extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mediaType.toString());
final MediaType contentType = body.contentType(); if (contentType != null) { headers.set(HttpHeaderNames.CONTENT_TYPE, contentType.toString());
if (contentType != null) { sink.writeUtf8("Content-Type: ") .writeUtf8(contentType.toString()) .write(CRLF);
responseFlowFile = session.putAttribute(responseFlowFile, CoreAttributes.MIME_TYPE.key(), responseBody.contentType().toString());
if (contentType != null) { sink.writeUtf8("Content-Type: ") .writeUtf8(contentType.toString()) .write(CRLF);
@Override public String getMimeType() { String contentType = myResponse.header(Constants.HEADER_CONTENT_TYPE); MediaType mediaType = null; if (contentType == null) { if (myResponse.body() != null) { mediaType = myResponse.body().contentType(); } } else { mediaType = MediaType.parse(contentType); } if (mediaType == null) { return null; } return typeAndSubtypeOnly(mediaType).toString(); }
ParseHttpResponse getResponse(Response okHttpResponse) { // Status code int statusCode = okHttpResponse.code(); // Content InputStream content = okHttpResponse.body().byteStream(); // Total size int totalSize = (int) okHttpResponse.body().contentLength(); // Reason phrase String reasonPhrase = okHttpResponse.message(); // Headers Map<String, String> headers = new HashMap<>(); for (String name : okHttpResponse.headers().names()) { headers.put(name, okHttpResponse.header(name)); } // Content type String contentType = null; ResponseBody body = okHttpResponse.body(); if (body != null && body.contentType() != null) { contentType = body.contentType().toString(); } return new ParseHttpResponse.Builder() .setStatusCode(statusCode) .setContent(content) .setTotalSize(totalSize) .setReasonPhrase(reasonPhrase) .setHeaders(headers) .setContentType(contentType) .build(); }
assertEquals(contentType, okHttpBody.contentType().toString());