Search in sources :

Example 1 with HTTPRequest

use of com.android.hotspot2.utils.HTTPRequest in project platform_frameworks_base by android.

the class HTTPHandler method httpExchange.

private HTTPResponse httpExchange(URL url, String message, HTTPMessage.Method method, String contentType) throws IOException {
    HTTPRequest request = new HTTPRequest(message, mCharset, method, url, contentType, false);
    request.send(mOut);
    HTTPResponse response = new HTTPResponse(mIn);
    Log.d(OSUManager.TAG, "HTTP code " + response.getStatusCode() + ", user " + mUser + ", pw " + (mPassword != null ? '\'' + new String(mPassword) + '\'' : "-"));
    if (response.getStatusCode() == 401) {
        if (mUser == null) {
            throw new IOException("Missing user name for HTTP authentication");
        }
        try {
            request = new HTTPRequest(message, StandardCharsets.ISO_8859_1, method, url, contentType, true);
            request.doAuthenticate(response, mUser, mPassword, url, sSequence.incrementAndGet());
            request.send(mOut);
            mHTTPAuthPerformed = true;
        } catch (GeneralSecurityException gse) {
            throw new IOException(gse);
        }
        response = new HTTPResponse(mIn);
    }
    return response;
}
Also used : HTTPRequest(com.android.hotspot2.utils.HTTPRequest) HTTPResponse(com.android.hotspot2.utils.HTTPResponse) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException)

Example 2 with HTTPRequest

use of com.android.hotspot2.utils.HTTPRequest in project android_frameworks_base by ResurrectionRemix.

the class HTTPHandler method httpExchange.

private HTTPResponse httpExchange(URL url, String message, HTTPMessage.Method method, String contentType) throws IOException {
    HTTPRequest request = new HTTPRequest(message, mCharset, method, url, contentType, false);
    request.send(mOut);
    HTTPResponse response = new HTTPResponse(mIn);
    Log.d(OSUManager.TAG, "HTTP code " + response.getStatusCode() + ", user " + mUser + ", pw " + (mPassword != null ? '\'' + new String(mPassword) + '\'' : "-"));
    if (response.getStatusCode() == 401) {
        if (mUser == null) {
            throw new IOException("Missing user name for HTTP authentication");
        }
        try {
            request = new HTTPRequest(message, StandardCharsets.ISO_8859_1, method, url, contentType, true);
            request.doAuthenticate(response, mUser, mPassword, url, sSequence.incrementAndGet());
            request.send(mOut);
            mHTTPAuthPerformed = true;
        } catch (GeneralSecurityException gse) {
            throw new IOException(gse);
        }
        response = new HTTPResponse(mIn);
    }
    return response;
}
Also used : HTTPRequest(com.android.hotspot2.utils.HTTPRequest) HTTPResponse(com.android.hotspot2.utils.HTTPResponse) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException)

Example 3 with HTTPRequest

use of com.android.hotspot2.utils.HTTPRequest in project android_frameworks_base by DirtyUnicorns.

the class HTTPHandler method httpExchange.

private HTTPResponse httpExchange(URL url, String message, HTTPMessage.Method method, String contentType) throws IOException {
    HTTPRequest request = new HTTPRequest(message, mCharset, method, url, contentType, false);
    request.send(mOut);
    HTTPResponse response = new HTTPResponse(mIn);
    Log.d(OSUManager.TAG, "HTTP code " + response.getStatusCode() + ", user " + mUser + ", pw " + (mPassword != null ? '\'' + new String(mPassword) + '\'' : "-"));
    if (response.getStatusCode() == 401) {
        if (mUser == null) {
            throw new IOException("Missing user name for HTTP authentication");
        }
        try {
            request = new HTTPRequest(message, StandardCharsets.ISO_8859_1, method, url, contentType, true);
            request.doAuthenticate(response, mUser, mPassword, url, sSequence.incrementAndGet());
            request.send(mOut);
            mHTTPAuthPerformed = true;
        } catch (GeneralSecurityException gse) {
            throw new IOException(gse);
        }
        response = new HTTPResponse(mIn);
    }
    return response;
}
Also used : HTTPRequest(com.android.hotspot2.utils.HTTPRequest) HTTPResponse(com.android.hotspot2.utils.HTTPResponse) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException)

Example 4 with HTTPRequest

use of com.android.hotspot2.utils.HTTPRequest in project android_frameworks_base by crdroidandroid.

the class HTTPHandler method httpExchange.

private HTTPResponse httpExchange(URL url, String message, HTTPMessage.Method method, String contentType) throws IOException {
    HTTPRequest request = new HTTPRequest(message, mCharset, method, url, contentType, false);
    request.send(mOut);
    HTTPResponse response = new HTTPResponse(mIn);
    Log.d(OSUManager.TAG, "HTTP code " + response.getStatusCode() + ", user " + mUser + ", pw " + (mPassword != null ? '\'' + new String(mPassword) + '\'' : "-"));
    if (response.getStatusCode() == 401) {
        if (mUser == null) {
            throw new IOException("Missing user name for HTTP authentication");
        }
        try {
            request = new HTTPRequest(message, StandardCharsets.ISO_8859_1, method, url, contentType, true);
            request.doAuthenticate(response, mUser, mPassword, url, sSequence.incrementAndGet());
            request.send(mOut);
            mHTTPAuthPerformed = true;
        } catch (GeneralSecurityException gse) {
            throw new IOException(gse);
        }
        response = new HTTPResponse(mIn);
    }
    return response;
}
Also used : HTTPRequest(com.android.hotspot2.utils.HTTPRequest) HTTPResponse(com.android.hotspot2.utils.HTTPResponse) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException)

Example 5 with HTTPRequest

use of com.android.hotspot2.utils.HTTPRequest in project android_frameworks_base by AOSPA.

the class HTTPHandler method httpExchange.

private HTTPResponse httpExchange(URL url, String message, HTTPMessage.Method method, String contentType) throws IOException {
    HTTPRequest request = new HTTPRequest(message, mCharset, method, url, contentType, false);
    request.send(mOut);
    HTTPResponse response = new HTTPResponse(mIn);
    Log.d(OSUManager.TAG, "HTTP code " + response.getStatusCode() + ", user " + mUser + ", pw " + (mPassword != null ? '\'' + new String(mPassword) + '\'' : "-"));
    if (response.getStatusCode() == 401) {
        if (mUser == null) {
            throw new IOException("Missing user name for HTTP authentication");
        }
        try {
            request = new HTTPRequest(message, StandardCharsets.ISO_8859_1, method, url, contentType, true);
            request.doAuthenticate(response, mUser, mPassword, url, sSequence.incrementAndGet());
            request.send(mOut);
            mHTTPAuthPerformed = true;
        } catch (GeneralSecurityException gse) {
            throw new IOException(gse);
        }
        response = new HTTPResponse(mIn);
    }
    return response;
}
Also used : HTTPRequest(com.android.hotspot2.utils.HTTPRequest) HTTPResponse(com.android.hotspot2.utils.HTTPResponse) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException)

Aggregations

HTTPRequest (com.android.hotspot2.utils.HTTPRequest)5 HTTPResponse (com.android.hotspot2.utils.HTTPResponse)5 IOException (java.io.IOException)5 GeneralSecurityException (java.security.GeneralSecurityException)5