12 changed files with 222 additions and 21 deletions
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
/* |
||||
* Copyright 2012-present the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.boot.http.client; |
||||
|
||||
import org.apache.hc.client5.http.cookie.StandardCookieSpec; |
||||
import org.jspecify.annotations.Nullable; |
||||
|
||||
/** |
||||
* Adapts {@link HttpCookies} to an |
||||
* <a href="https://hc.apache.org/httpcomponents-client-ga/">Apache HttpComponents</a> |
||||
* cookie spec identifier. |
||||
* |
||||
* @author Apoorv Darshan |
||||
*/ |
||||
final class HttpComponentsCookieSpec { |
||||
|
||||
private HttpComponentsCookieSpec() { |
||||
} |
||||
|
||||
static @Nullable String get(@Nullable HttpCookies cookies) { |
||||
if (cookies == null) { |
||||
return null; |
||||
} |
||||
return switch (cookies) { |
||||
case ENABLE_WHEN_POSSIBLE, ENABLE -> StandardCookieSpec.STRICT; |
||||
case DISABLE -> StandardCookieSpec.IGNORE; |
||||
}; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
/* |
||||
* Copyright 2012-present the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.boot.http.client; |
||||
|
||||
/** |
||||
* Cookie handling strategies supported by HTTP clients. |
||||
* |
||||
* @author Apoorv Darshan |
||||
* @since 4.1.0 |
||||
*/ |
||||
public enum HttpCookies { |
||||
|
||||
/** |
||||
* Enable cookies (if the underlying library has support). |
||||
*/ |
||||
ENABLE_WHEN_POSSIBLE, |
||||
|
||||
/** |
||||
* Enable cookies (fail if the underlying library has no support). |
||||
*/ |
||||
ENABLE, |
||||
|
||||
/** |
||||
* Disable cookies (fail if the underlying library has no support). |
||||
*/ |
||||
DISABLE |
||||
|
||||
} |
||||
Loading…
Reference in new issue