equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
41 import java.net.http.HttpClient; |
41 import java.net.http.HttpClient; |
42 import java.net.http.HttpHeaders; |
42 import java.net.http.HttpHeaders; |
43 import java.net.http.HttpRequest; |
43 import java.net.http.HttpRequest; |
44 import jdk.internal.net.http.common.HttpHeadersBuilder; |
44 import jdk.internal.net.http.common.HttpHeadersBuilder; |
45 import jdk.internal.net.http.common.Utils; |
45 import jdk.internal.net.http.common.Utils; |
|
46 import jdk.internal.net.http.websocket.OpeningHandshake; |
46 import jdk.internal.net.http.websocket.WebSocketRequest; |
47 import jdk.internal.net.http.websocket.WebSocketRequest; |
47 |
48 |
48 import static jdk.internal.net.http.common.Utils.ALLOWED_HEADERS; |
49 import static jdk.internal.net.http.common.Utils.ALLOWED_HEADERS; |
49 |
50 |
50 public class HttpRequestImpl extends HttpRequest implements WebSocketRequest { |
51 public class HttpRequestImpl extends HttpRequest implements WebSocketRequest { |
155 return new HttpRequestImpl(uri, method, other); |
156 return new HttpRequestImpl(uri, method, other); |
156 } |
157 } |
157 |
158 |
158 /** Returns a new instance suitable for authentication. */ |
159 /** Returns a new instance suitable for authentication. */ |
159 public static HttpRequestImpl newInstanceForAuthentication(HttpRequestImpl other) { |
160 public static HttpRequestImpl newInstanceForAuthentication(HttpRequestImpl other) { |
160 return new HttpRequestImpl(other.uri(), other.method(), other); |
161 HttpRequestImpl request = new HttpRequestImpl(other.uri(), other.method(), other); |
|
162 if (request.isWebSocket()) { |
|
163 Utils.setWebSocketUpgradeHeaders(request); |
|
164 } |
|
165 return request; |
161 } |
166 } |
162 |
167 |
163 /** |
168 /** |
164 * Creates a HttpRequestImpl using fields of an existing request impl. |
169 * Creates a HttpRequestImpl using fields of an existing request impl. |
165 * The newly created HttpRequestImpl does not copy the system headers. |
170 * The newly created HttpRequestImpl does not copy the system headers. |