/** HTTP status message or null if unknown. */ public String message() { return rawResponse.message(); }
@Override public String getResponseMessage() throws IOException { return response.message(); }
@Override public String getStatusText() { return this.response.message(); }
@Override public String reasonPhrase() { return mResponse.message(); }
public String message() { if (rawResponse == null) return null; return rawResponse.message(); }
@Override public String getStatusText() { return this.response.message(); }
/** HTTP status message or null if unknown. */ public String message() { return rawResponse.message(); }
@Override public String getResponseMessage() throws IOException { return getResponse(true).message(); }
private static String formatMessage(Response response) { if (response == null) { return "Empty HTTP response"; } return "HTTP " + response.code() + " " + response.message(); } }
Entry(Response response) { this.url = response.request().url().toString(); this.varyHeaders = HttpHeaders.varyHeaders(response); this.requestMethod = response.request().method(); this.protocol = response.protocol(); this.code = response.code(); this.message = response.message(); this.responseHeaders = response.headers(); this.handshake = response.handshake(); this.sentRequestMillis = response.sentRequestAtMillis(); this.receivedResponseMillis = response.receivedResponseAtMillis(); }
public static StatusLine get(Response response) { return new StatusLine(response.protocol(), response.code(), response.message()); }
public ApolloHttpException(@Nullable okhttp3.Response rawResponse) { super(formatMessage(rawResponse)); this.code = rawResponse != null ? rawResponse.code() : 0; this.message = rawResponse != null ? rawResponse.message() : ""; this.rawResponse = rawResponse; }
@Override public void onResponse(@NonNull Call call, @NonNull Response response) { responseBody = response.body(); if (response.isSuccessful()) { long contentLength = Preconditions.checkNotNull(responseBody).contentLength(); stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength); callback.onDataReady(stream); } else { callback.onLoadFailed(new HttpException(response.message(), response.code())); } }
public static StatusLine get(Response response) { return new StatusLine(response.protocol(), response.code(), response.message()); }
private static HttpResponse transformResponse(Response response) { int code = response.code(); String message = response.message(); BasicHttpResponse httpResponse = new BasicHttpResponse(HTTP_1_1, code, message); ResponseBody body = response.body(); InputStreamEntity entity = new InputStreamEntity(body.byteStream(), body.contentLength()); httpResponse.setEntity(entity); Headers headers = response.headers(); for (int i = 0, size = headers.size(); i < size; i++) { String name = headers.name(i); String value = headers.value(i); httpResponse.addHeader(name, value); if ("Content-Type".equalsIgnoreCase(name)) { entity.setContentType(value); } else if ("Content-Encoding".equalsIgnoreCase(name)) { entity.setContentEncoding(value); } } return httpResponse; }
Entry(Response response) { this.url = response.request().url().toString(); this.varyHeaders = HttpHeaders.varyHeaders(response); this.requestMethod = response.request().method(); this.protocol = response.protocol(); this.code = response.code(); this.message = response.message(); this.responseHeaders = response.headers(); this.handshake = response.handshake(); this.sentRequestMillis = response.sentRequestAtMillis(); this.receivedResponseMillis = response.receivedResponseAtMillis(); }
@Override public void onResponse(@NonNull Call call, @NonNull Response response) { responseBody = response.body(); if (response.isSuccessful()) { long contentLength = Preconditions.checkNotNull(responseBody).contentLength(); stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength); callback.onDataReady(stream); } else { callback.onLoadFailed(new HttpException(response.message(), response.code())); } }
ResponseHeaderRecord(Response response) { this.url = response.request().url().toString(); this.varyHeaders = HttpHeaders.varyHeaders(response); this.requestMethod = response.request().method(); this.protocol = response.protocol(); this.code = response.code(); this.message = response.message(); this.responseHeaders = response.headers(); this.handshake = response.handshake(); this.sentRequestMillis = response.sentRequestAtMillis(); this.receivedResponseMillis = response.receivedResponseAtMillis(); }
private List<InetAddress> readResponse(String hostname, Response response) throws Exception { if (response.cacheResponse() == null && response.protocol() != Protocol.HTTP_2) { Platform.get().log(Platform.WARN, "Incorrect protocol: " + response.protocol(), null); } try { if (!response.isSuccessful()) { throw new IOException("response: " + response.code() + " " + response.message()); } ResponseBody body = response.body(); if (body.contentLength() > MAX_RESPONSE_SIZE) { throw new IOException("response size exceeds limit (" + MAX_RESPONSE_SIZE + " bytes): " + body.contentLength() + " bytes"); } ByteString responseBytes = body.source().readByteString(); return DnsRecordCodec.decodeAnswers(hostname, responseBytes); } finally { response.close(); } }
void checkResponse(Response response) throws ProtocolException { if (response.code() != 101) { throw new ProtocolException("Expected HTTP 101 response but was '" + response.code() + " " + response.message() + "'"); } String headerConnection = response.header("Connection"); if (!"Upgrade".equalsIgnoreCase(headerConnection)) { throw new ProtocolException("Expected 'Connection' header value 'Upgrade' but was '" + headerConnection + "'"); } String headerUpgrade = response.header("Upgrade"); if (!"websocket".equalsIgnoreCase(headerUpgrade)) { throw new ProtocolException( "Expected 'Upgrade' header value 'websocket' but was '" + headerUpgrade + "'"); } String headerAccept = response.header("Sec-WebSocket-Accept"); String acceptExpected = ByteString.encodeUtf8(key + WebSocketProtocol.ACCEPT_MAGIC) .sha1().base64(); if (!acceptExpected.equals(headerAccept)) { throw new ProtocolException("Expected 'Sec-WebSocket-Accept' header value '" + acceptExpected + "' but was '" + headerAccept + "'"); } }