use of java.net.CookieHandler in project cordova-android-chromeview by thedracle.
the class HttpEngine method prepareRawRequestHeaders.
/**
* Populates requestHeaders with defaults and cookies.
*
* <p>This client doesn't specify a default {@code Accept} header because it
* doesn't know what content types the application is interested in.
*/
private void prepareRawRequestHeaders() throws IOException {
requestHeaders.getHeaders().setRequestLine(getRequestLine());
if (requestHeaders.getUserAgent() == null) {
requestHeaders.setUserAgent(getDefaultUserAgent());
}
if (requestHeaders.getHost() == null) {
requestHeaders.setHost(getOriginAddress(policy.getURL()));
}
if ((connection == null || connection.getHttpMinorVersion() != 0) && requestHeaders.getConnection() == null) {
requestHeaders.setConnection("Keep-Alive");
}
if (requestHeaders.getAcceptEncoding() == null) {
transparentGzip = true;
requestHeaders.setAcceptEncoding("gzip");
}
if (hasRequestBody() && requestHeaders.getContentType() == null) {
requestHeaders.setContentType("application/x-www-form-urlencoded");
}
long ifModifiedSince = policy.getIfModifiedSince();
if (ifModifiedSince != 0) {
requestHeaders.setIfModifiedSince(new Date(ifModifiedSince));
}
CookieHandler cookieHandler = policy.cookieHandler;
if (cookieHandler != null) {
requestHeaders.addCookies(cookieHandler.get(uri, requestHeaders.getHeaders().toMultimap(false)));
}
}
use of java.net.CookieHandler in project XobotOS by xamarin.
the class HttpEngine method readHeaders.
private void readHeaders(RawHeaders headers) throws IOException {
// parse the result headers until the first blank line
String line;
while (!(line = Streams.readAsciiLine(socketIn)).isEmpty()) {
headers.addLine(line);
}
CookieHandler cookieHandler = CookieHandler.getDefault();
if (cookieHandler != null) {
cookieHandler.put(uri, headers.toMultimap());
}
}
use of java.net.CookieHandler in project jdk8u_jdk by JetBrains.
the class HttpOnly method test.
void test(String[] args) throws Exception {
HttpServer server = startHttpServer();
CookieHandler previousHandler = CookieHandler.getDefault();
try {
InetSocketAddress address = server.getAddress();
URI uri = new URI("http://" + InetAddress.getLocalHost().getHostAddress() + ":" + address.getPort() + URI_PATH);
populateCookieStore(uri);
doClient(uri);
} finally {
CookieHandler.setDefault(previousHandler);
server.stop(0);
}
}
Aggregations