문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
java:httpclient [2023/11/28 08:45] kwon37xi [Connection Pool] |
java:httpclient [2023/11/28 10:44] (현재) kwon37xi [일부 헤더가 사라지는 문제] |
||
|---|---|---|---|
| 줄 10: | 줄 10: | ||
| ==== 일부 헤더가 사라지는 문제 ==== | ==== 일부 헤더가 사라지는 문제 ==== | ||
| * 일부 헤더('' | * 일부 헤더('' | ||
| - | * 이것은 문제는 아니고, 의도된 것인데 System Property 를 지정해주면된다. | + | |
| + | | ||
| < | < | ||
| # 대소문자 안 가림 | # 대소문자 안 가림 | ||
| jdk.httpclient.allowRestrictedHeaders=host, | jdk.httpclient.allowRestrictedHeaders=host, | ||
| + | # sec- 헤더는 이것만으로는 해결이 안됨. | ||
| </ | </ | ||
| * 참조 : [[https:// | * 참조 : [[https:// | ||
| + | * 헌데, '' | ||
| + | ==== SSL 에서 memory leak ==== | ||
| + | * [[https:// | ||
| + | * Java 19 미만 버전의 경우 '' | ||
| + | * '' | ||
| + | |||
| + | |||
| + | ===== 인증 / Authentication ===== | ||
| + | * [[https:// | ||
| + | * Basic Auth('' | ||
| + | <code java> | ||
| + | HttpClient client = HttpClient.newBuilder() | ||
| + | .authenticator(new Authenticator() { | ||
| + | @Override | ||
| + | protected PasswordAuthentication getPasswordAuthentication() { | ||
| + | return new PasswordAuthentication("< | ||
| + | } | ||
| + | }) | ||
| + | .build(); | ||
| + | </ | ||
| + | * '' | ||
| + | * [[https:// | ||
| + | <code java> | ||
| + | // header 직접 설정방식 | ||
| + | private static final String getBasicAuthenticationHeader(String username, String password) { | ||
| + | String valueToEncode = username + ":" | ||
| + | return "Basic " + Base64.getEncoder().encodeToString(valueToEncode.getBytes()); | ||
| + | } | ||
| + | |||
| + | HttpRequest request = HttpRequest.newBuilder() | ||
| + | .GET() | ||
| + | .uri(new URI(" | ||
| + | .header(" | ||
| + | .build(); | ||
| + | </ | ||
| ===== Connection Pool ===== | ===== Connection Pool ===== | ||
| * Keep Alive Timeout : System Property '' | * Keep Alive Timeout : System Property '' | ||