import typing

import android.content
import android.net
import android.os
import java
import java.chaquopy
import java.io
import java.lang
import java.net
import java.nio
import java.security.cert
import java.time
import java.util
import java.util.concurrent
import javax.net.ssl

class BidirectionalStream(java.lang.Object):
    STREAM_PRIORITY_HIGHEST: typing.ClassVar[int] = ...
    STREAM_PRIORITY_IDLE: typing.ClassVar[int] = ...
    STREAM_PRIORITY_LOW: typing.ClassVar[int] = ...
    STREAM_PRIORITY_LOWEST: typing.ClassVar[int] = ...
    STREAM_PRIORITY_MEDIUM: typing.ClassVar[int] = ...
    def __init__(self) -> None: ...
    def cancel(self) -> None: ...
    def flush(self) -> None: ...
    def getHeaders(self) -> HeaderBlock: ...
    def getHttpMethod(self) -> str: ...
    def getPriority(self) -> int: ...
    def getTrafficStatsTag(self) -> int: ...
    def getTrafficStatsUid(self) -> int: ...
    def hasTrafficStatsTag(self) -> bool: ...
    def hasTrafficStatsUid(self) -> bool: ...
    def isDelayRequestHeadersUntilFirstFlushEnabled(self) -> bool: ...
    def isDone(self) -> bool: ...
    def read(self, arg1: java.nio.ByteBuffer, /) -> None: ...
    def start(self) -> None: ...
    def write(self, arg1: java.nio.ByteBuffer, arg2: bool | java.jboolean | java.lang.Boolean, /) -> None: ...

    class Callback(java.lang.Object):
        def onCanceled(self, arg1: BidirectionalStream, arg2: UrlResponseInfo, /) -> None: ...
        def onFailed(self, arg1: BidirectionalStream, arg2: UrlResponseInfo, arg3: HttpException, /) -> None: ...
        def onReadCompleted(self, arg1: BidirectionalStream, arg2: UrlResponseInfo, arg3: java.nio.ByteBuffer, arg4: bool | java.jboolean | java.lang.Boolean, /) -> None: ...
        def onResponseHeadersReceived(self, arg1: BidirectionalStream, arg2: UrlResponseInfo, /) -> None: ...
        def onResponseTrailersReceived(self, arg1: BidirectionalStream, arg2: UrlResponseInfo, arg3: HeaderBlock, /) -> None: ...
        def onStreamReady(self, arg1: BidirectionalStream, /) -> None: ...
        def onSucceeded(self, arg1: BidirectionalStream, arg2: UrlResponseInfo, /) -> None: ...
        def onWriteCompleted(self, arg1: BidirectionalStream, arg2: UrlResponseInfo, arg3: java.nio.ByteBuffer, arg4: bool | java.jboolean | java.lang.Boolean, /) -> None: ...

    class Builder(java.lang.Object):
        def __init__(self) -> None: ...
        def addHeader(self, arg1: str | java.lang.String, arg2: str | java.lang.String, /) -> BidirectionalStream.Builder: ...
        def build(self) -> BidirectionalStream: ...
        def setDelayRequestHeadersUntilFirstFlushEnabled(self, arg1: bool | java.jboolean | java.lang.Boolean, /) -> BidirectionalStream.Builder: ...
        def setHttpMethod(self, arg1: str | java.lang.String, /) -> BidirectionalStream.Builder: ...
        def setPriority(self, arg1: int | java.jint | java.lang.Integer, /) -> BidirectionalStream.Builder: ...
        def setTrafficStatsTag(self, arg1: int | java.jint | java.lang.Integer, /) -> BidirectionalStream.Builder: ...
        def setTrafficStatsUid(self, arg1: int | java.jint | java.lang.Integer, /) -> BidirectionalStream.Builder: ...

class CallbackException(HttpException):
    def __init__(self, message: str | java.lang.String, cause: java.lang.Throwable, /) -> None: ...

class ConnectionMigrationOptions(java.lang.Object):
    MIGRATION_OPTION_DISABLED: typing.ClassVar[int] = ...
    MIGRATION_OPTION_ENABLED: typing.ClassVar[int] = ...
    MIGRATION_OPTION_UNSPECIFIED: typing.ClassVar[int] = ...
    def getAllowNonDefaultNetworkUsage(self) -> int: ...
    def getDefaultNetworkMigration(self) -> int: ...
    def getPathDegradationMigration(self) -> int: ...

    class Builder(java.lang.Object):
        def __init__(self) -> None: ...
        def build(self) -> ConnectionMigrationOptions: ...
        def setAllowNonDefaultNetworkUsage(self, state: int | java.jint | java.lang.Integer, /) -> ConnectionMigrationOptions.Builder: ...
        def setDefaultNetworkMigration(self, state: int | java.jint | java.lang.Integer, /) -> ConnectionMigrationOptions.Builder: ...
        def setPathDegradationMigration(self, state: int | java.jint | java.lang.Integer, /) -> ConnectionMigrationOptions.Builder: ...

class DnsOptions(java.lang.Object):
    DNS_OPTION_DISABLED: typing.ClassVar[int] = ...
    DNS_OPTION_ENABLED: typing.ClassVar[int] = ...
    DNS_OPTION_UNSPECIFIED: typing.ClassVar[int] = ...
    def getPersistHostCache(self) -> int: ...
    def getPersistHostCachePeriod(self) -> java.time.Duration | None: ...
    def getPreestablishConnectionsToStaleDnsResults(self) -> int: ...
    def getStaleDns(self) -> int: ...
    def getStaleDnsOptions(self) -> DnsOptions.StaleDnsOptions | None: ...
    def getUseHttpStackDnsResolver(self) -> int: ...

    class StaleDnsOptions(java.lang.Object):
        def getAllowCrossNetworkUsage(self) -> int: ...
        def getFreshLookupTimeout(self) -> java.time.Duration: ...
        def getMaxExpiredDelay(self) -> java.time.Duration: ...
        def getUseStaleOnNameNotResolved(self) -> int: ...

        class Builder(java.lang.Object):
            def __init__(self) -> None: ...
            def build(self) -> DnsOptions.StaleDnsOptions: ...
            def setAllowCrossNetworkUsage(self, state: int | java.jint | java.lang.Integer, /) -> DnsOptions.StaleDnsOptions.Builder: ...
            def setFreshLookupTimeout(self, freshLookupTimeout: java.time.Duration, /) -> DnsOptions.StaleDnsOptions.Builder: ...
            def setMaxExpiredDelay(self, maxExpiredDelay: java.time.Duration, /) -> DnsOptions.StaleDnsOptions.Builder: ...
            def setUseStaleOnNameNotResolved(self, state: int | java.jint | java.lang.Integer, /) -> DnsOptions.StaleDnsOptions.Builder: ...

    class Builder(java.lang.Object):
        def __init__(self) -> None: ...
        def build(self) -> DnsOptions: ...
        def setPersistHostCache(self, state: int | java.jint | java.lang.Integer, /) -> DnsOptions.Builder: ...
        def setPersistHostCachePeriod(self, persistHostCachePeriod: java.time.Duration, /) -> DnsOptions.Builder: ...
        def setPreestablishConnectionsToStaleDnsResults(self, state: int | java.jint | java.lang.Integer, /) -> DnsOptions.Builder: ...
        def setStaleDns(self, state: int | java.jint | java.lang.Integer, /) -> DnsOptions.Builder: ...
        def setStaleDnsOptions(self, staleDnsOptions: DnsOptions.StaleDnsOptions, /) -> DnsOptions.Builder: ...
        def setUseHttpStackDnsResolver(self, state: int | java.jint | java.lang.Integer, /) -> DnsOptions.Builder: ...

class HeaderBlock(java.lang.Object):
    def __init__(self) -> None: ...
    def getAsList(self) -> java.util.List[java.util.Map.Entry[java.lang.String, java.lang.String]]: ...
    def getAsMap(self) -> java.util.Map[java.lang.String, java.util.List[java.lang.String]]: ...

class HttpEngine(java.lang.Object):
    def bindToNetwork(self, network: android.net.Network, /) -> None: ...
    def createUrlStreamHandlerFactory(self) -> java.net.URLStreamHandlerFactory: ...
    @staticmethod
    def getVersionString() -> str: ...
    def newBidirectionalStreamBuilder(self, arg1: str | java.lang.String, arg2: java.util.concurrent.Executor, arg3: BidirectionalStream.Callback, /) -> BidirectionalStream.Builder: ...
    def newUrlRequestBuilder(self, arg1: str | java.lang.String, arg2: java.util.concurrent.Executor, arg3: UrlRequest.Callback, /) -> UrlRequest.Builder: ...
    def openConnection(self, arg1: java.net.URL, /) -> java.net.URLConnection: ...
    def shutdown(self) -> None: ...

    class Builder(java.lang.Object):
        HTTP_CACHE_DISABLED: typing.ClassVar[int] = ...
        HTTP_CACHE_DISK: typing.ClassVar[int] = ...
        HTTP_CACHE_DISK_NO_HTTP: typing.ClassVar[int] = ...
        HTTP_CACHE_IN_MEMORY: typing.ClassVar[int] = ...
        def __init__(self, context: android.content.Context, /) -> None: ...
        def addPublicKeyPins(self, hostName: str | java.lang.String, pinsSha256: java.util.Set[java.chaquopy.JavaArrayJByte], includeSubdomains: bool | java.jboolean | java.lang.Boolean, expirationInstant: java.time.Instant, /) -> HttpEngine.Builder: ...
        def addQuicHint(self, host: str | java.lang.String, port: int | java.jint | java.lang.Integer, alternatePort: int | java.jint | java.lang.Integer, /) -> HttpEngine.Builder: ...
        def build(self) -> HttpEngine: ...
        def getDefaultUserAgent(self) -> str: ...
        def setConnectionMigrationOptions(self, connectionMigrationOptions: ConnectionMigrationOptions, /) -> HttpEngine.Builder: ...
        def setDnsOptions(self, dnsOptions: DnsOptions, /) -> HttpEngine.Builder: ...
        def setEnableBrotli(self, value: bool | java.jboolean | java.lang.Boolean, /) -> HttpEngine.Builder: ...
        def setEnableHttp2(self, value: bool | java.jboolean | java.lang.Boolean, /) -> HttpEngine.Builder: ...
        def setEnableHttpCache(self, cacheMode: int | java.jint | java.lang.Integer, maxSize: int | java.jlong | java.lang.Long, /) -> HttpEngine.Builder: ...
        def setEnablePublicKeyPinningBypassForLocalTrustAnchors(self, value: bool | java.jboolean | java.lang.Boolean, /) -> HttpEngine.Builder: ...
        def setEnableQuic(self, value: bool | java.jboolean | java.lang.Boolean, /) -> HttpEngine.Builder: ...
        def setQuicOptions(self, quicOptions: QuicOptions, /) -> HttpEngine.Builder: ...
        def setStoragePath(self, value: str | java.lang.String, /) -> HttpEngine.Builder: ...
        def setUserAgent(self, userAgent: str | java.lang.String, /) -> HttpEngine.Builder: ...

class HttpException(java.io.IOException):
    def __init__(self, message: str | java.lang.String, cause: java.lang.Throwable, /) -> None: ...

class HttpResponseCache(java.io.Closeable, java.net.ResponseCache):
    def close(self) -> None: ...
    def delete(self) -> None: ...
    def flush(self) -> None: ...
    def get(self, uri: java.net.URI, requestMethod: str | java.lang.String, requestHeaders: java.util.Map[java.lang.String, java.util.List[java.lang.String]], /) -> java.net.CacheResponse: ...
    def getHitCount(self) -> int: ...
    @staticmethod
    def getInstalled() -> HttpResponseCache: ...
    def getNetworkCount(self) -> int: ...
    def getRequestCount(self) -> int: ...
    @staticmethod
    def install(directory: java.io.File, maxSize: int | java.jlong | java.lang.Long, /) -> HttpResponseCache: ...
    def maxSize(self) -> int: ...
    def put(self, uri: java.net.URI, urlConnection: java.net.URLConnection, /) -> java.net.CacheRequest: ...
    def size(self) -> int: ...

class InlineExecutionProhibitedException(java.util.concurrent.RejectedExecutionException):
    def __init__(self) -> None: ...

class NetworkException(HttpException):
    ERROR_ADDRESS_UNREACHABLE: typing.ClassVar[int] = ...
    ERROR_CONNECTION_CLOSED: typing.ClassVar[int] = ...
    ERROR_CONNECTION_REFUSED: typing.ClassVar[int] = ...
    ERROR_CONNECTION_RESET: typing.ClassVar[int] = ...
    ERROR_CONNECTION_TIMED_OUT: typing.ClassVar[int] = ...
    ERROR_HOSTNAME_NOT_RESOLVED: typing.ClassVar[int] = ...
    ERROR_INTERNET_DISCONNECTED: typing.ClassVar[int] = ...
    ERROR_NETWORK_CHANGED: typing.ClassVar[int] = ...
    ERROR_OTHER: typing.ClassVar[int] = ...
    ERROR_QUIC_PROTOCOL_FAILED: typing.ClassVar[int] = ...
    ERROR_TIMED_OUT: typing.ClassVar[int] = ...
    def __init__(self, message: str | java.lang.String, cause: java.lang.Throwable, /) -> None: ...
    def getErrorCode(self) -> int: ...
    def isImmediatelyRetryable(self) -> bool: ...

class QuicException(NetworkException):
    def __init__(self, message: str | java.lang.String, cause: java.lang.Throwable, /) -> None: ...

class QuicOptions(java.lang.Object):
    def getAllowedQuicHosts(self) -> java.util.Set[java.lang.String]: ...
    def getHandshakeUserAgent(self) -> str | None: ...
    def getIdleConnectionTimeout(self) -> java.time.Duration | None: ...
    def getInMemoryServerConfigsCacheSize(self) -> int: ...
    def hasInMemoryServerConfigsCacheSize(self) -> bool: ...

    class Builder(java.lang.Object):
        def __init__(self) -> None: ...
        def addAllowedQuicHost(self, quicHost: str | java.lang.String, /) -> QuicOptions.Builder: ...
        def build(self) -> QuicOptions: ...
        def setHandshakeUserAgent(self, handshakeUserAgent: str | java.lang.String, /) -> QuicOptions.Builder: ...
        def setIdleConnectionTimeout(self, idleConnectionTimeout: java.time.Duration, /) -> QuicOptions.Builder: ...
        def setInMemoryServerConfigsCacheSize(self, inMemoryServerConfigsCacheSize: int | java.jint | java.lang.Integer, /) -> QuicOptions.Builder: ...

class SslCertificate(java.lang.Object):
    @typing.overload
    def __init__(self, certificate: java.security.cert.X509Certificate, /) -> None: ...
    @typing.overload
    def __init__(self, issuedTo: str | java.lang.String, issuedBy: str | java.lang.String, validNotBefore: str | java.lang.String, validNotAfter: str | java.lang.String, /) -> None: ...
    @typing.overload
    def __init__(self, issuedTo: str | java.lang.String, issuedBy: str | java.lang.String, validNotBefore: java.util.Date, validNotAfter: java.util.Date, /) -> None: ...
    def getIssuedBy(self) -> SslCertificate.DName | None: ...
    def getIssuedTo(self) -> SslCertificate.DName | None: ...
    def getValidNotAfter(self) -> str: ...
    def getValidNotAfterDate(self) -> java.util.Date: ...
    def getValidNotBefore(self) -> str: ...
    def getValidNotBeforeDate(self) -> java.util.Date: ...
    def getX509Certificate(self) -> java.security.cert.X509Certificate | None: ...
    @staticmethod
    def restoreState(bundle: android.os.Bundle, /) -> SslCertificate | None: ...
    @staticmethod
    def saveState(certificate: SslCertificate, /) -> android.os.Bundle | None: ...
    def toString(self) -> str: ...

    class DName(java.lang.Object):
        def __init__(self, this_0: SslCertificate, dName: str | java.lang.String, /) -> None: ...
        def getCName(self) -> str: ...
        def getDName(self) -> str: ...
        def getOName(self) -> str: ...
        def getUName(self) -> str: ...

class SslError(java.lang.Object):
    SSL_DATE_INVALID: typing.ClassVar[int] = ...
    SSL_EXPIRED: typing.ClassVar[int] = ...
    SSL_IDMISMATCH: typing.ClassVar[int] = ...
    SSL_INVALID: typing.ClassVar[int] = ...
    SSL_MAX_ERROR: typing.ClassVar[int] = ...
    SSL_NOTYETVALID: typing.ClassVar[int] = ...
    SSL_UNTRUSTED: typing.ClassVar[int] = ...
    @typing.overload
    def __init__(self, error: int | java.jint | java.lang.Integer, certificate: SslCertificate, /) -> None: ...
    @typing.overload
    def __init__(self, error: int | java.jint | java.lang.Integer, certificate: java.security.cert.X509Certificate, /) -> None: ...
    @typing.overload
    def __init__(self, error: int | java.jint | java.lang.Integer, certificate: SslCertificate, url: str | java.lang.String, /) -> None: ...
    @typing.overload
    def __init__(self, error: int | java.jint | java.lang.Integer, certificate: java.security.cert.X509Certificate, url: str | java.lang.String, /) -> None: ...
    def addError(self, error: int | java.jint | java.lang.Integer, /) -> bool: ...
    def getCertificate(self) -> SslCertificate: ...
    def getPrimaryError(self) -> int: ...
    def getUrl(self) -> str: ...
    def hasError(self, error: int | java.jint | java.lang.Integer, /) -> bool: ...
    def toString(self) -> str: ...

class UploadDataProvider(java.io.Closeable):
    def __init__(self) -> None: ...
    def close(self) -> None: ...
    def getLength(self) -> int: ...
    def read(self, arg1: UploadDataSink, arg2: java.nio.ByteBuffer, /) -> None: ...
    def rewind(self, arg1: UploadDataSink, /) -> None: ...

class UploadDataSink(java.lang.Object):
    def __init__(self) -> None: ...
    def onReadError(self, arg1: java.lang.Exception, /) -> None: ...
    def onReadSucceeded(self, arg1: bool | java.jboolean | java.lang.Boolean, /) -> None: ...
    def onRewindError(self, arg1: java.lang.Exception, /) -> None: ...
    def onRewindSucceeded(self) -> None: ...

class UrlRequest(java.lang.Object):
    REQUEST_PRIORITY_HIGHEST: typing.ClassVar[int] = ...
    REQUEST_PRIORITY_IDLE: typing.ClassVar[int] = ...
    REQUEST_PRIORITY_LOW: typing.ClassVar[int] = ...
    REQUEST_PRIORITY_LOWEST: typing.ClassVar[int] = ...
    REQUEST_PRIORITY_MEDIUM: typing.ClassVar[int] = ...
    def cancel(self) -> None: ...
    def followRedirect(self) -> None: ...
    def getHeaders(self) -> HeaderBlock: ...
    def getHttpMethod(self) -> str | None: ...
    def getPriority(self) -> int: ...
    def getStatus(self, arg1: UrlRequest.StatusListener, /) -> None: ...
    def getTrafficStatsTag(self) -> int: ...
    def getTrafficStatsUid(self) -> int: ...
    def hasTrafficStatsTag(self) -> bool: ...
    def hasTrafficStatsUid(self) -> bool: ...
    def isCacheDisabled(self) -> bool: ...
    def isDirectExecutorAllowed(self) -> bool: ...
    def isDone(self) -> bool: ...
    def read(self, arg1: java.nio.ByteBuffer, /) -> None: ...
    def start(self) -> None: ...

    class StatusListener(java.lang.Object):
        def onStatus(self, arg1: int | java.jint | java.lang.Integer, /) -> None: ...

    class Status(java.lang.Object):
        CONNECTING: typing.ClassVar[int] = ...
        DOWNLOADING_PAC_FILE: typing.ClassVar[int] = ...
        ESTABLISHING_PROXY_TUNNEL: typing.ClassVar[int] = ...
        IDLE: typing.ClassVar[int] = ...
        INVALID: typing.ClassVar[int] = ...
        READING_RESPONSE: typing.ClassVar[int] = ...
        RESOLVING_HOST: typing.ClassVar[int] = ...
        RESOLVING_HOST_IN_PAC_FILE: typing.ClassVar[int] = ...
        RESOLVING_PROXY_FOR_URL: typing.ClassVar[int] = ...
        SENDING_REQUEST: typing.ClassVar[int] = ...
        SSL_HANDSHAKE: typing.ClassVar[int] = ...
        WAITING_FOR_AVAILABLE_SOCKET: typing.ClassVar[int] = ...
        WAITING_FOR_CACHE: typing.ClassVar[int] = ...
        WAITING_FOR_DELEGATE: typing.ClassVar[int] = ...
        WAITING_FOR_RESPONSE: typing.ClassVar[int] = ...
        WAITING_FOR_STALLED_SOCKET_POOL: typing.ClassVar[int] = ...

    class Callback(java.lang.Object):
        def onCanceled(self, arg1: UrlRequest, arg2: UrlResponseInfo, /) -> None: ...
        def onFailed(self, arg1: UrlRequest, arg2: UrlResponseInfo, arg3: HttpException, /) -> None: ...
        def onReadCompleted(self, arg1: UrlRequest, arg2: UrlResponseInfo, arg3: java.nio.ByteBuffer, /) -> None: ...
        def onRedirectReceived(self, arg1: UrlRequest, arg2: UrlResponseInfo, arg3: str | java.lang.String, /) -> None: ...
        def onResponseStarted(self, arg1: UrlRequest, arg2: UrlResponseInfo, /) -> None: ...
        def onSucceeded(self, arg1: UrlRequest, arg2: UrlResponseInfo, /) -> None: ...

    class Builder(java.lang.Object):
        def addHeader(self, arg1: str | java.lang.String, arg2: str | java.lang.String, /) -> UrlRequest.Builder: ...
        def bindToNetwork(self, arg1: android.net.Network, /) -> UrlRequest.Builder: ...
        def build(self) -> UrlRequest: ...
        def setCacheDisabled(self, arg1: bool | java.jboolean | java.lang.Boolean, /) -> UrlRequest.Builder: ...
        def setDirectExecutorAllowed(self, arg1: bool | java.jboolean | java.lang.Boolean, /) -> UrlRequest.Builder: ...
        def setHttpMethod(self, arg1: str | java.lang.String, /) -> UrlRequest.Builder: ...
        def setPriority(self, arg1: int | java.jint | java.lang.Integer, /) -> UrlRequest.Builder: ...
        def setTrafficStatsTag(self, arg1: int | java.jint | java.lang.Integer, /) -> UrlRequest.Builder: ...
        def setTrafficStatsUid(self, arg1: int | java.jint | java.lang.Integer, /) -> UrlRequest.Builder: ...
        def setUploadDataProvider(self, arg1: UploadDataProvider, arg2: java.util.concurrent.Executor, /) -> UrlRequest.Builder: ...

class UrlResponseInfo(java.lang.Object):
    def __init__(self) -> None: ...
    def getHeaders(self) -> HeaderBlock: ...
    def getHttpStatusCode(self) -> int: ...
    def getHttpStatusText(self) -> str: ...
    def getNegotiatedProtocol(self) -> str: ...
    def getReceivedByteCount(self) -> int: ...
    def getUrl(self) -> str: ...
    def getUrlChain(self) -> java.util.List[java.lang.String]: ...
    def wasCached(self) -> bool: ...

class X509TrustManagerExtensions(java.lang.Object):
    def __init__(self, tm: javax.net.ssl.X509TrustManager, /) -> None: ...
    @typing.overload
    def checkServerTrusted(self, chain: java.chaquopy.JavaArray[java.security.cert.X509Certificate], authType: str | java.lang.String, host: str | java.lang.String, /) -> java.util.List[java.security.cert.X509Certificate]: ...
    @typing.overload
    def checkServerTrusted(self, chain: java.chaquopy.JavaArray[java.security.cert.X509Certificate], ocspData: java.chaquopy.JavaArrayJByte, tlsSctData: java.chaquopy.JavaArrayJByte, authType: str | java.lang.String, host: str | java.lang.String, /) -> java.util.List[java.security.cert.X509Certificate]: ...
    def isSameTrustConfiguration(self, hostname1: str | java.lang.String, hostname2: str | java.lang.String, /) -> bool: ...
    def isUserAddedCertificate(self, cert: java.security.cert.X509Certificate, /) -> bool: ...
