use of okhttp3.internal.http.StatusLine in project apollo-android by apollographql.
the class ResponseHeaderRecord method writeTo.
void writeTo(Sink sink) throws IOException {
BufferedSink bufferedSink = Okio.buffer(sink);
bufferedSink.writeUtf8(url).writeByte('\n');
bufferedSink.writeUtf8(requestMethod).writeByte('\n');
bufferedSink.writeDecimalLong(varyHeaders.size()).writeByte('\n');
for (int i = 0, size = varyHeaders.size(); i < size; i++) {
bufferedSink.writeUtf8(varyHeaders.name(i)).writeUtf8(": ").writeUtf8(varyHeaders.value(i)).writeByte('\n');
}
bufferedSink.writeUtf8(new StatusLine(protocol, code, message).toString()).writeByte('\n');
bufferedSink.writeDecimalLong(responseHeaders.size() + 2).writeByte('\n');
for (int i = 0, size = responseHeaders.size(); i < size; i++) {
bufferedSink.writeUtf8(responseHeaders.name(i)).writeUtf8(": ").writeUtf8(responseHeaders.value(i)).writeByte('\n');
}
bufferedSink.writeUtf8(SENT_MILLIS).writeUtf8(": ").writeDecimalLong(sentRequestMillis).writeByte('\n');
bufferedSink.writeUtf8(RECEIVED_MILLIS).writeUtf8(": ").writeDecimalLong(receivedResponseMillis).writeByte('\n');
if (isHttps()) {
bufferedSink.writeByte('\n');
bufferedSink.writeUtf8(handshake.cipherSuite().javaName()).writeByte('\n');
writeCertList(bufferedSink, handshake.peerCertificates());
writeCertList(bufferedSink, handshake.localCertificates());
// The handshake's TLS version is null on HttpsURLConnection and on older cached responses.
if (handshake.tlsVersion() != null) {
bufferedSink.writeUtf8(handshake.tlsVersion().javaName()).writeByte('\n');
}
}
bufferedSink.close();
}
Aggregations