Tabnine Logo
Response.protocol
Code IndexAdd Tabnine to your IDE (free)

How to use
protocol
method
in
okhttp3.Response

Best Java code snippets using okhttp3.Response.protocol (Showing top 20 results out of 315)

origin: square/okhttp

public static StatusLine get(Response response) {
 return new StatusLine(response.protocol(), response.code(), response.message());
}
origin: square/okhttp

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();
}
origin: square/okhttp

 private static void sendRequest(OkHttpClient client, String url) {
  System.out.printf("%-40s ", url);
  System.out.flush();

  System.out.println(Platform.get());

  Request request = new Request.Builder().url(url).build();

  try (Response response = client.newCall(request).execute()) {
   Handshake handshake = response.handshake();
   System.out.println(handshake.tlsVersion()
     + " "
     + handshake.cipherSuite()
     + " "
     + response.protocol()
     + " "
     + response.code
     + " "
     + response.body.bytes().length
     + "b");
  } catch (IOException ioe) {
   System.out.println(ioe.toString());
  }
 }
}
origin: com.squareup.okhttp3/okhttp

public static StatusLine get(Response response) {
 return new StatusLine(response.protocol(), response.code(), response.message());
}
origin: square/okhttp

  + response.networkResponse().code()
  + " over "
  + response.protocol()
  + ")") : "(cache)";
int responseCode = response.code();
origin: square/okhttp

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();
 }
}
origin: com.squareup.okhttp3/okhttp

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();
}
origin: apollographql/apollo-android

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();
}
origin: square/okhttp

private Headers getHeaders() throws IOException {
 if (responseHeaders == null) {
  Response response = getResponse(true);
  Headers headers = response.headers();
  responseHeaders = headers.newBuilder()
    .add(SELECTED_PROTOCOL, response.protocol().toString())
    .add(RESPONSE_SOURCE, responseSourceHeader(response))
    .build();
 }
 return responseHeaders;
}
origin: jgilfelt/chuck

transaction.setProtocol(response.protocol().toString());
transaction.setResponseCode(response.code());
transaction.setResponseMessage(response.message());
origin: foxinmy/weixin4j

@Override
public HttpVersion getProtocol() {
  if (protocol == null) {
    String protocol = this.response.protocol().toString().split("/")[0];
    boolean keepAlive = KEEP_ALIVE.equalsIgnoreCase(this.response
        .header("Connection"));
    if (this.response.protocol() == Protocol.HTTP_1_0) {
      return new HttpVersion(protocol, 1, 0, keepAlive);
    } else if (this.response.protocol() == Protocol.HTTP_1_1) {
      return new HttpVersion(protocol, 1, 1, keepAlive);
    } else if (this.response.protocol() == Protocol.HTTP_2) {
      return new HttpVersion(protocol, 2, 0, keepAlive);
    } else if (this.response.protocol() == Protocol.SPDY_3) {
      return new HttpVersion(protocol, 3, 0, keepAlive);
    } else {
      this.protocol = new HttpVersion(protocol, keepAlive);
    }
  }
  return protocol;
}
origin: com.github.icecooly/FastHttpClient

/**
 * 
 * @return
 */
public Protocol protocol() {
  return response.protocol();
}
origin: zalando/logbook

@Override
public String getProtocolVersion() {
  // see https://tools.ietf.org/html/rfc7230#section-2.6
  return response.protocol().toString().toUpperCase(Locale.ROOT);
}
origin: duzechao/OKHttpUtils

public Entry(Response response) {
 this.url = response.request().url().toString();
 this.varyHeaders = OkHeaders.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();
}
origin: huxq17/SwipeCardsView

public Entry(Response response) {
 this.url = response.request().url().toString();
 this.varyHeaders = OkHeaders.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();
}
origin: huxq17/tractor

public Entry(Response response) {
 this.url = response.request().url().toString();
 this.varyHeaders = OkHeaders.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();
}
origin: com.github.ljun20160606/okhttp

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();
}
origin: allegro/hermes

  HermesResponse fromOkHttpResponse(Response response) throws IOException {
    return hermesResponse()
        .withHeaderSupplier(response::header)
        .withHttpStatus(response.code())
        .withBody(response.body().string())
        .withProtocol(response.protocol().toString())
        .build();
  }
}
origin: airbnb/okreplay

/** Construct a OkReplay Response based on the provided OkHttp response */
static Response adapt(final okhttp3.Response okhttpResponse, ResponseBody body) {
 return new RecordedResponse.Builder()
   .headers(okhttpResponse.headers())
   .body(body)
   .protocol(okhttpResponse.protocol())
   .code(okhttpResponse.code())
   .build();
}
origin: com.squareup.okhttp3/okhttp-urlconnection

private Headers getHeaders() throws IOException {
 if (responseHeaders == null) {
  Response response = getResponse(true);
  Headers headers = response.headers();
  responseHeaders = headers.newBuilder()
    .add(SELECTED_PROTOCOL, response.protocol().toString())
    .add(RESPONSE_SOURCE, responseSourceHeader(response))
    .build();
 }
 return responseHeaders;
}
okhttp3Responseprotocol

Javadoc

Returns the HTTP protocol, such as Protocol#HTTP_1_1 or Protocol#HTTP_1_0.

Popular methods of Response

  • body
    Returns a non-null value if this response was passed to Callback#onResponse or returned from Call#ex
  • code
    Returns the HTTP status code.
  • isSuccessful
    Returns true if the code is in [200..300), which means the request was successfully received, unders
  • headers
  • request
    The wire-level request that initiated this HTTP response. This is not necessarily the same request i
  • newBuilder
  • message
    Returns the HTTP status message.
  • header
  • close
    Closes the response body. Equivalent to body().close().It is an error to close a response that is no
  • networkResponse
    Returns the raw response received from the network. Will be null if this response didn't use the net
  • cacheResponse
    Returns the raw response received from the cache. Will be null if this response didn't use the cache
  • toString
  • cacheResponse,
  • toString,
  • handshake,
  • priorResponse,
  • sentRequestAtMillis,
  • cacheControl,
  • challenges,
  • peekBody,
  • receivedResponseAtMillis

Popular in Java

  • Reactive rest calls using spring rest template
  • requestLocationUpdates (LocationManager)
  • getApplicationContext (Context)
  • addToBackStack (FragmentTransaction)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Top 17 PhpStorm Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now