what-the-bank/sources/okhttp3/internal/http/RequestLine.java

51 lines
1.5 KiB
Java

package okhttp3.internal.http;
import java.net.Proxy;
import o.C14957gcv;
import okhttp3.HttpUrl;
import okhttp3.Request;
/* loaded from: classes.dex */
public final class RequestLine {
public static final RequestLine INSTANCE = new RequestLine();
private RequestLine() {
}
public final String get(Request request, Proxy.Type type) {
C14957gcv.e(request, "");
C14957gcv.e(type, "");
StringBuilder sb = new StringBuilder();
sb.append(request.method());
sb.append(' ');
RequestLine requestLine = INSTANCE;
if (requestLine.includeAuthorityInRequestLine(request, type)) {
sb.append(request.url());
} else {
sb.append(requestLine.requestPath(request.url()));
}
sb.append(" HTTP/1.1");
String obj = sb.toString();
C14957gcv.c((Object) obj, "");
return obj;
}
private final boolean includeAuthorityInRequestLine(Request request, Proxy.Type type) {
return !request.isHttps() && type == Proxy.Type.HTTP;
}
public final String requestPath(HttpUrl httpUrl) {
C14957gcv.e(httpUrl, "");
String encodedPath = httpUrl.encodedPath();
String encodedQuery = httpUrl.encodedQuery();
if (encodedQuery == null) {
return encodedPath;
}
StringBuilder sb = new StringBuilder();
sb.append(encodedPath);
sb.append('?');
sb.append((Object) encodedQuery);
return sb.toString();
}
}