alexandroid/decompiled/jadx/sources/org/apache/http/impl/SocketHttpServerConnection.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

172 lines
5.7 KiB
Java

package org.apache.http.impl;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketException;
import kotlinx.serialization.json.internal.AbstractJsonLexerKt;
import org.apache.http.HttpInetConnection;
import org.apache.http.impl.io.SocketInputBuffer;
import org.apache.http.impl.io.SocketOutputBuffer;
import org.apache.http.io.SessionInputBuffer;
import org.apache.http.io.SessionOutputBuffer;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.params.HttpParams;
import org.apache.http.util.Args;
import org.apache.http.util.Asserts;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@Deprecated
/* loaded from: classes11.dex */
public class SocketHttpServerConnection extends AbstractHttpServerConnection implements HttpInetConnection {
private volatile boolean open;
private volatile Socket socket = null;
private static void formatAddress(StringBuilder sb, SocketAddress socketAddress) {
if (!(socketAddress instanceof InetSocketAddress)) {
sb.append(socketAddress);
return;
}
InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
sb.append(inetSocketAddress.getAddress() != null ? inetSocketAddress.getAddress().getHostAddress() : inetSocketAddress.getAddress());
sb.append(AbstractJsonLexerKt.COLON);
sb.append(inetSocketAddress.getPort());
}
public void assertNotOpen() {
Asserts.check(!this.open, "Connection is already open");
}
@Override // org.apache.http.impl.AbstractHttpServerConnection
public void assertOpen() {
Asserts.check(this.open, "Connection is not open");
}
public void bind(Socket socket, HttpParams httpParams) throws IOException {
Args.notNull(socket, "Socket");
Args.notNull(httpParams, "HTTP parameters");
this.socket = socket;
int intParameter = httpParams.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
init(createSessionInputBuffer(socket, intParameter, httpParams), createSessionOutputBuffer(socket, intParameter, httpParams), httpParams);
this.open = true;
}
@Override // org.apache.http.HttpConnection, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
if (this.open) {
this.open = false;
this.open = false;
Socket socket = this.socket;
try {
doFlush();
try {
try {
socket.shutdownOutput();
} catch (IOException unused) {
}
socket.shutdownInput();
} catch (IOException | UnsupportedOperationException unused2) {
}
} finally {
socket.close();
}
}
}
public SessionInputBuffer createSessionInputBuffer(Socket socket, int i, HttpParams httpParams) throws IOException {
return new SocketInputBuffer(socket, i, httpParams);
}
public SessionOutputBuffer createSessionOutputBuffer(Socket socket, int i, HttpParams httpParams) throws IOException {
return new SocketOutputBuffer(socket, i, httpParams);
}
@Override // org.apache.http.HttpInetConnection
public InetAddress getLocalAddress() {
if (this.socket != null) {
return this.socket.getLocalAddress();
}
return null;
}
@Override // org.apache.http.HttpInetConnection
public int getLocalPort() {
if (this.socket != null) {
return this.socket.getLocalPort();
}
return -1;
}
@Override // org.apache.http.HttpInetConnection
public InetAddress getRemoteAddress() {
if (this.socket != null) {
return this.socket.getInetAddress();
}
return null;
}
@Override // org.apache.http.HttpInetConnection
public int getRemotePort() {
if (this.socket != null) {
return this.socket.getPort();
}
return -1;
}
public Socket getSocket() {
return this.socket;
}
@Override // org.apache.http.HttpConnection
public int getSocketTimeout() {
if (this.socket != null) {
try {
return this.socket.getSoTimeout();
} catch (SocketException unused) {
}
}
return -1;
}
@Override // org.apache.http.HttpConnection
public boolean isOpen() {
return this.open;
}
@Override // org.apache.http.HttpConnection
public void setSocketTimeout(int i) {
assertOpen();
if (this.socket != null) {
try {
this.socket.setSoTimeout(i);
} catch (SocketException unused) {
}
}
}
@Override // org.apache.http.HttpConnection
public void shutdown() throws IOException {
this.open = false;
Socket socket = this.socket;
if (socket != null) {
socket.close();
}
}
public String toString() {
if (this.socket == null) {
return super.toString();
}
StringBuilder sb = new StringBuilder();
SocketAddress remoteSocketAddress = this.socket.getRemoteSocketAddress();
SocketAddress localSocketAddress = this.socket.getLocalSocketAddress();
if (remoteSocketAddress != null && localSocketAddress != null) {
formatAddress(sb, localSocketAddress);
sb.append("<->");
formatAddress(sb, remoteSocketAddress);
}
return sb.toString();
}
}