.class public final Lokhttp3/internal/http/CallServerInterceptor; .super Ljava/lang/Object; .source "" # interfaces .implements Lokhttp3/Interceptor; # annotations .annotation system Ldalvik/annotation/MemberClasses; value = { Lokhttp3/internal/http/CallServerInterceptor$CountingSink; } .end annotation # instance fields .field private final forWebSocket:Z # direct methods .method public constructor (Z)V .locals 0 invoke-direct {p0}, Ljava/lang/Object;->()V iput-boolean p1, p0, Lokhttp3/internal/http/CallServerInterceptor;->forWebSocket:Z return-void .end method # virtual methods .method public intercept(Lokhttp3/Interceptor$Chain;)Lokhttp3/Response; .locals 11 .annotation system Ldalvik/annotation/Throws; value = { Ljava/io/IOException; } .end annotation check-cast p1, Lokhttp3/internal/http/RealInterceptorChain; invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->httpStream()Lokhttp3/internal/http/HttpCodec; move-result-object v0 invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->streamAllocation()Lokhttp3/internal/connection/StreamAllocation; move-result-object v1 invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->connection()Lokhttp3/Connection; move-result-object v2 check-cast v2, Lokhttp3/internal/connection/RealConnection; invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->request()Lokhttp3/Request; move-result-object v3 invoke-static {}, Ljava/lang/System;->currentTimeMillis()J move-result-wide v4 invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->eventListener()Lokhttp3/EventListener; move-result-object v6 invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->call()Lokhttp3/Call; move-result-object v7 invoke-virtual {v6, v7}, Lokhttp3/EventListener;->requestHeadersStart(Lokhttp3/Call;)V invoke-interface {v0, v3}, Lokhttp3/internal/http/HttpCodec;->writeRequestHeaders(Lokhttp3/Request;)V invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->eventListener()Lokhttp3/EventListener; move-result-object v6 invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->call()Lokhttp3/Call; move-result-object v7 invoke-virtual {v6, v7, v3}, Lokhttp3/EventListener;->requestHeadersEnd(Lokhttp3/Call;Lokhttp3/Request;)V invoke-virtual {v3}, Lokhttp3/Request;->method()Ljava/lang/String; move-result-object v6 invoke-static {v6}, Lokhttp3/internal/http/HttpMethod;->permitsRequestBody(Ljava/lang/String;)Z move-result v6 const/4 v7, 0x0 if-eqz v6, :cond_2 invoke-virtual {v3}, Lokhttp3/Request;->body()Lokhttp3/RequestBody; move-result-object v6 if-eqz v6, :cond_2 const-string v6, "Expect" invoke-virtual {v3, v6}, Lokhttp3/Request;->header(Ljava/lang/String;)Ljava/lang/String; move-result-object v6 const-string v8, "100-continue" invoke-virtual {v8, v6}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z move-result v6 if-eqz v6, :cond_0 invoke-interface {v0}, Lokhttp3/internal/http/HttpCodec;->flushRequest()V invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->eventListener()Lokhttp3/EventListener; move-result-object v6 invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->call()Lokhttp3/Call; move-result-object v7 invoke-virtual {v6, v7}, Lokhttp3/EventListener;->responseHeadersStart(Lokhttp3/Call;)V const/4 v6, 0x1 invoke-interface {v0, v6}, Lokhttp3/internal/http/HttpCodec;->readResponseHeaders(Z)Lokhttp3/Response$Builder; move-result-object v7 :cond_0 if-nez v7, :cond_1 invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->eventListener()Lokhttp3/EventListener; move-result-object v2 invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->call()Lokhttp3/Call; move-result-object v6 invoke-virtual {v2, v6}, Lokhttp3/EventListener;->requestBodyStart(Lokhttp3/Call;)V invoke-virtual {v3}, Lokhttp3/Request;->body()Lokhttp3/RequestBody; move-result-object v2 invoke-virtual {v2}, Lokhttp3/RequestBody;->contentLength()J move-result-wide v8 new-instance v2, Lokhttp3/internal/http/CallServerInterceptor$CountingSink; invoke-interface {v0, v3, v8, v9}, Lokhttp3/internal/http/HttpCodec;->createRequestBody(Lokhttp3/Request;J)Lokio/Sink; move-result-object v6 invoke-direct {v2, v6}, Lokhttp3/internal/http/CallServerInterceptor$CountingSink;->(Lokio/Sink;)V invoke-static {v2}, Lokio/Okio;->buffer(Lokio/Sink;)Lokio/BufferedSink; move-result-object v6 invoke-virtual {v3}, Lokhttp3/Request;->body()Lokhttp3/RequestBody; move-result-object v8 invoke-virtual {v8, v6}, Lokhttp3/RequestBody;->writeTo(Lokio/BufferedSink;)V invoke-interface {v6}, Lokio/Sink;->close()V invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->eventListener()Lokhttp3/EventListener; move-result-object v6 invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->call()Lokhttp3/Call; move-result-object v8 iget-wide v9, v2, Lokhttp3/internal/http/CallServerInterceptor$CountingSink;->successfulCount:J invoke-virtual {v6, v8, v9, v10}, Lokhttp3/EventListener;->requestBodyEnd(Lokhttp3/Call;J)V goto :goto_0 :cond_1 invoke-virtual {v2}, Lokhttp3/internal/connection/RealConnection;->isMultiplexed()Z move-result v2 if-nez v2, :cond_2 invoke-virtual {v1}, Lokhttp3/internal/connection/StreamAllocation;->noNewStreams()V :cond_2 :goto_0 invoke-interface {v0}, Lokhttp3/internal/http/HttpCodec;->finishRequest()V if-nez v7, :cond_3 invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->eventListener()Lokhttp3/EventListener; move-result-object v2 invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->call()Lokhttp3/Call; move-result-object v6 invoke-virtual {v2, v6}, Lokhttp3/EventListener;->responseHeadersStart(Lokhttp3/Call;)V const/4 v2, 0x0 invoke-interface {v0, v2}, Lokhttp3/internal/http/HttpCodec;->readResponseHeaders(Z)Lokhttp3/Response$Builder; move-result-object v7 :cond_3 invoke-virtual {v7, v3}, Lokhttp3/Response$Builder;->request(Lokhttp3/Request;)Lokhttp3/Response$Builder; move-result-object v2 invoke-virtual {v1}, Lokhttp3/internal/connection/StreamAllocation;->connection()Lokhttp3/internal/connection/RealConnection; move-result-object v3 invoke-virtual {v3}, Lokhttp3/internal/connection/RealConnection;->handshake()Lokhttp3/Handshake; move-result-object v3 invoke-virtual {v2, v3}, Lokhttp3/Response$Builder;->handshake(Lokhttp3/Handshake;)Lokhttp3/Response$Builder; move-result-object v2 invoke-virtual {v2, v4, v5}, Lokhttp3/Response$Builder;->sentRequestAtMillis(J)Lokhttp3/Response$Builder; move-result-object v2 invoke-static {}, Ljava/lang/System;->currentTimeMillis()J move-result-wide v3 invoke-virtual {v2, v3, v4}, Lokhttp3/Response$Builder;->receivedResponseAtMillis(J)Lokhttp3/Response$Builder; move-result-object v2 invoke-virtual {v2}, Lokhttp3/Response$Builder;->build()Lokhttp3/Response; move-result-object v2 invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->eventListener()Lokhttp3/EventListener; move-result-object v3 invoke-virtual {p1}, Lokhttp3/internal/http/RealInterceptorChain;->call()Lokhttp3/Call; move-result-object p1 invoke-virtual {v3, p1, v2}, Lokhttp3/EventListener;->responseHeadersEnd(Lokhttp3/Call;Lokhttp3/Response;)V invoke-virtual {v2}, Lokhttp3/Response;->code()I move-result p1 iget-boolean v3, p0, Lokhttp3/internal/http/CallServerInterceptor;->forWebSocket:Z if-eqz v3, :cond_4 const/16 v3, 0x65 if-ne p1, v3, :cond_4 invoke-virtual {v2}, Lokhttp3/Response;->newBuilder()Lokhttp3/Response$Builder; move-result-object v0 sget-object v2, Lokhttp3/internal/Util;->EMPTY_RESPONSE:Lokhttp3/ResponseBody; invoke-virtual {v0, v2}, Lokhttp3/Response$Builder;->body(Lokhttp3/ResponseBody;)Lokhttp3/Response$Builder; move-result-object v0 goto :goto_1 :cond_4 invoke-virtual {v2}, Lokhttp3/Response;->newBuilder()Lokhttp3/Response$Builder; move-result-object v3 invoke-interface {v0, v2}, Lokhttp3/internal/http/HttpCodec;->openResponseBody(Lokhttp3/Response;)Lokhttp3/ResponseBody; move-result-object v0 invoke-virtual {v3, v0}, Lokhttp3/Response$Builder;->body(Lokhttp3/ResponseBody;)Lokhttp3/Response$Builder; move-result-object v0 :goto_1 invoke-virtual {v0}, Lokhttp3/Response$Builder;->build()Lokhttp3/Response; move-result-object v0 invoke-virtual {v0}, Lokhttp3/Response;->request()Lokhttp3/Request; move-result-object v2 const-string v3, "Connection" invoke-virtual {v2, v3}, Lokhttp3/Request;->header(Ljava/lang/String;)Ljava/lang/String; move-result-object v2 const-string v4, "close" invoke-virtual {v4, v2}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z move-result v2 if-nez v2, :cond_5 invoke-virtual {v0, v3}, Lokhttp3/Response;->header(Ljava/lang/String;)Ljava/lang/String; move-result-object v2 invoke-virtual {v4, v2}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z move-result v2 if-eqz v2, :cond_6 :cond_5 invoke-virtual {v1}, Lokhttp3/internal/connection/StreamAllocation;->noNewStreams()V :cond_6 const/16 v1, 0xcc if-eq p1, v1, :cond_7 const/16 v1, 0xcd if-ne p1, v1, :cond_8 :cond_7 invoke-virtual {v0}, Lokhttp3/Response;->body()Lokhttp3/ResponseBody; move-result-object v1 invoke-virtual {v1}, Lokhttp3/ResponseBody;->contentLength()J move-result-wide v1 const-wide/16 v3, 0x0 cmp-long v5, v1, v3 if-gtz v5, :cond_9 :cond_8 return-object v0 :cond_9 new-instance v1, Ljava/net/ProtocolException; new-instance v2, Ljava/lang/StringBuilder; invoke-direct {v2}, Ljava/lang/StringBuilder;->()V const-string v3, "HTTP " invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder; const-string p1, " had non-zero Content-Length: " invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; invoke-virtual {v0}, Lokhttp3/Response;->body()Lokhttp3/ResponseBody; move-result-object p1 invoke-virtual {p1}, Lokhttp3/ResponseBody;->contentLength()J move-result-wide v3 invoke-virtual {v2, v3, v4}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder; invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; move-result-object p1 invoke-direct {v1, p1}, Ljava/net/ProtocolException;->(Ljava/lang/String;)V throw v1 .end method