1 /*
2 * Copyright (c) 2002-2026 Gargoyle Software Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * https://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 package org.htmlunit.httpclient;
16
17 import org.apache.http.cookie.ClientCookie;
18 import org.htmlunit.http.Cookie;
19
20 /**
21 * Wrapper for {@link ClientCookie}.
22 *
23 * @author Ronald Brill
24 */
25 public class HttpClientCookie extends Cookie {
26
27 private final ClientCookie httpClientCookie_;
28
29 /**
30 * Creates a new HtmlUnit cookie from the HttpClient cookie provided.
31 * @param clientCookie the HttpClient cookie
32 */
33 public HttpClientCookie(final ClientCookie clientCookie) {
34 // just use this ctor but in fact we will overwrite by setting the httpClient Cookie
35 super(clientCookie.getDomain(), clientCookie.getName(),
36 clientCookie.getValue(), clientCookie.getPath(),
37 clientCookie.getExpiryDate(), clientCookie.isSecure(),
38 clientCookie.getAttribute("httponly") != null, clientCookie.getAttribute("samesite"));
39
40 httpClientCookie_ = clientCookie;
41 }
42
43 /**
44 * @return an HttpClient ClientCookie version of this cookie
45 */
46 public ClientCookie getHttpClientCookie() {
47 return httpClientCookie_;
48 }
49 }