From 6a8700d7e32a3cb8ea0a4a61598b493401cba4aa Mon Sep 17 00:00:00 2001 From: Andrei Arlou Date: Tue, 11 Jun 2024 21:44:39 +0300 Subject: [PATCH] 4.x: Replace deprecated method Header.value() on Header.get() --- .../testing/http/junit5/HttpHeaderMatcher.java | 4 ++-- .../security/basicauth/BasicExampleTest.java | 2 +- .../examples/webserver/echo/EchoClient.java | 4 ++-- .../encoding/ContentEncodingSupportImpl.java | 4 ++-- .../helidon/http/ClientResponseHeadersImpl.java | 4 ++-- .../io/helidon/http/ServerRequestHeaders.java | 10 +++++----- .../helidon/http/ServerRequestHeadersImpl.java | 2 +- .../io/helidon/http/ContentDispositionTest.java | 4 ++-- .../java/io/helidon/http/http2/Http2Headers.java | 6 +++--- .../io/helidon/http/http2/Http2HeadersTest.java | 14 +++++++------- .../media/multipart/ReadablePartAbstract.java | 4 ++-- .../integrations/common/rest/RestApiTest.java | 4 ++-- .../webclient/http1/Http1CallChainBase.java | 2 +- .../http1/Http1CallOutputStreamChain.java | 8 ++++---- .../webclient/http1/RedirectionProcessor.java | 2 +- .../webclient/websocket/WsClientImpl.java | 4 ++-- .../helidon/webserver/cors/AbstractCorsTest.java | 16 ++++++++-------- .../webserver/http1/Http1ServerRequest.java | 2 +- .../helidon/webserver/websocket/WsUpgrader.java | 8 ++++---- 19 files changed, 52 insertions(+), 52 deletions(-) diff --git a/common/testing/http-junit5/src/main/java/io/helidon/common/testing/http/junit5/HttpHeaderMatcher.java b/common/testing/http-junit5/src/main/java/io/helidon/common/testing/http/junit5/HttpHeaderMatcher.java index 49eb2b41651..a75c30f41c3 100644 --- a/common/testing/http-junit5/src/main/java/io/helidon/common/testing/http/junit5/HttpHeaderMatcher.java +++ b/common/testing/http-junit5/src/main/java/io/helidon/common/testing/http/junit5/HttpHeaderMatcher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Oracle and/or its affiliates. + * Copyright (c) 2022, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -217,7 +217,7 @@ protected boolean matchesSafely(Headers httpHeaders) { if (httpHeaders.contains(name)) { Header headerValue = httpHeaders.get(name); if (headerValue.allValues().size() == 1) { - return valuesMatcher.matches(headerValue.value()); + return valuesMatcher.matches(headerValue.get()); } return false; } diff --git a/examples/security/basic-auth-with-static-content/src/test/java/io/helidon/examples/security/basicauth/BasicExampleTest.java b/examples/security/basic-auth-with-static-content/src/test/java/io/helidon/examples/security/basicauth/BasicExampleTest.java index 34874e6ab2c..37a9a72414d 100644 --- a/examples/security/basic-auth-with-static-content/src/test/java/io/helidon/examples/security/basicauth/BasicExampleTest.java +++ b/examples/security/basic-auth-with-static-content/src/test/java/io/helidon/examples/security/basicauth/BasicExampleTest.java @@ -132,7 +132,7 @@ private void testNotAuthorized(String uri) { try (Http1ClientResponse response = client.get().uri(uri).request()) { assertThat(response.status(), is(Status.UNAUTHORIZED_401)); - String header = response.headers().get(HeaderNames.WWW_AUTHENTICATE).value(); + String header = response.headers().get(HeaderNames.WWW_AUTHENTICATE).get(); assertThat(header.toLowerCase(), containsString("basic")); assertThat(header, containsString("helidon")); diff --git a/examples/webserver/echo/src/main/java/io/helidon/examples/webserver/echo/EchoClient.java b/examples/webserver/echo/src/main/java/io/helidon/examples/webserver/echo/EchoClient.java index 933fa093bfb..0460ff49fe3 100644 --- a/examples/webserver/echo/src/main/java/io/helidon/examples/webserver/echo/EchoClient.java +++ b/examples/webserver/echo/src/main/java/io/helidon/examples/webserver/echo/EchoClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Oracle and/or its affiliates. + * Copyright (c) 2022, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ public static void main(String[] args) { Headers headers = response.headers(); for (Header header : headers) { - System.out.println("Header: " + header.name() + "=" + header.value()); + System.out.println("Header: " + header.name() + "=" + header.get()); } System.out.println("Entity:"); System.out.println(response.as(String.class)); diff --git a/http/encoding/encoding/src/main/java/io/helidon/http/encoding/ContentEncodingSupportImpl.java b/http/encoding/encoding/src/main/java/io/helidon/http/encoding/ContentEncodingSupportImpl.java index 2b52b6da4d2..0215f447d3b 100644 --- a/http/encoding/encoding/src/main/java/io/helidon/http/encoding/ContentEncodingSupportImpl.java +++ b/http/encoding/encoding/src/main/java/io/helidon/http/encoding/ContentEncodingSupportImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Oracle and/or its affiliates. + * Copyright (c) 2022, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -120,7 +120,7 @@ public ContentEncoder encoder(Headers headers) { return ContentEncoder.NO_OP; } - String acceptEncoding = headers.get(HeaderNames.ACCEPT_ENCODING).value(); + String acceptEncoding = headers.get(HeaderNames.ACCEPT_ENCODING).get(); /* Accept-Encoding: gzip Accept-Encoding: gzip, compress, br diff --git a/http/http/src/main/java/io/helidon/http/ClientResponseHeadersImpl.java b/http/http/src/main/java/io/helidon/http/ClientResponseHeadersImpl.java index 3b90ec2969a..1ed604d5185 100644 --- a/http/http/src/main/java/io/helidon/http/ClientResponseHeadersImpl.java +++ b/http/http/src/main/java/io/helidon/http/ClientResponseHeadersImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Oracle and/or its affiliates. + * Copyright (c) 2022, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ public Header get(HeaderName name) { public Optional contentType() { if (parserMode == ParserMode.RELAXED) { return contains(HeaderNameEnum.CONTENT_TYPE) - ? Optional.of(HttpMediaType.create(get(HeaderNameEnum.CONTENT_TYPE).value(), parserMode)) + ? Optional.of(HttpMediaType.create(get(HeaderNameEnum.CONTENT_TYPE).get(), parserMode)) : Optional.empty(); } return headers.contentType(); diff --git a/http/http/src/main/java/io/helidon/http/ServerRequestHeaders.java b/http/http/src/main/java/io/helidon/http/ServerRequestHeaders.java index 38cd32c9b9a..528b21e1af0 100644 --- a/http/http/src/main/java/io/helidon/http/ServerRequestHeaders.java +++ b/http/http/src/main/java/io/helidon/http/ServerRequestHeaders.java @@ -78,7 +78,7 @@ static ServerRequestHeaders create() { default Optional ifModifiedSince() { if (contains(HeaderNames.IF_MODIFIED_SINCE)) { return Optional.of(get(HeaderNames.IF_MODIFIED_SINCE)) - .map(Header::value) + .map(Header::get) .map(DateTime::parse); } @@ -95,7 +95,7 @@ default Optional ifModifiedSince() { default Optional ifUnmodifiedSince() { if (contains(HeaderNames.IF_UNMODIFIED_SINCE)) { return Optional.of(get(HeaderNames.IF_UNMODIFIED_SINCE)) - .map(Header::value) + .map(Header::get) .map(DateTime::parse); } return Optional.empty(); @@ -189,7 +189,7 @@ default Parameters cookies() { default Optional acceptDatetime() { if (contains(HeaderNames.ACCEPT_DATETIME)) { return Optional.of(get(HeaderNames.ACCEPT_DATETIME)) - .map(Header::value) + .map(Header::get) .map(DateTime::parse); } return Optional.empty(); @@ -203,7 +203,7 @@ default Optional acceptDatetime() { default Optional date() { if (contains(HeaderNames.DATE)) { return Optional.of(get(HeaderNames.DATE)) - .map(Header::value) + .map(Header::get) .map(DateTime::parse); } return Optional.empty(); @@ -221,7 +221,7 @@ default Optional date() { default Optional referer() { if (contains(HeaderNames.REFERER)) { return Optional.of(get(HeaderNames.REFERER)) - .map(Header::value) + .map(Header::get) .map(URI::create); } return Optional.empty(); diff --git a/http/http/src/main/java/io/helidon/http/ServerRequestHeadersImpl.java b/http/http/src/main/java/io/helidon/http/ServerRequestHeadersImpl.java index 20b5d066645..ef48b992bca 100644 --- a/http/http/src/main/java/io/helidon/http/ServerRequestHeadersImpl.java +++ b/http/http/src/main/java/io/helidon/http/ServerRequestHeadersImpl.java @@ -77,7 +77,7 @@ public List acceptedTypes() { List acceptedTypes; List acceptValues = all(HeaderNames.ACCEPT, List::of); - if (acceptValues.size() == 1 && HUC_ACCEPT_DEFAULT.value().equals(acceptValues.get(0))) { + if (acceptValues.size() == 1 && HUC_ACCEPT_DEFAULT.get().equals(acceptValues.get(0))) { acceptedTypes = HUC_ACCEPT_DEFAULT_TYPES; } else { acceptedTypes = new ArrayList<>(5); diff --git a/http/http/src/test/java/io/helidon/http/ContentDispositionTest.java b/http/http/src/test/java/io/helidon/http/ContentDispositionTest.java index bef61a70b63..3a012cb3290 100644 --- a/http/http/src/test/java/io/helidon/http/ContentDispositionTest.java +++ b/http/http/src/test/java/io/helidon/http/ContentDispositionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Oracle and/or its affiliates. + * Copyright (c) 2022, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -224,7 +224,7 @@ void testQuotes() { .filename("file.txt") .size(300) .build(); - assertThat(cd.value(), is(equalTo(template))); + assertThat(cd.get(), is(equalTo(template))); } @Test diff --git a/http/http2/src/main/java/io/helidon/http/http2/Http2Headers.java b/http/http2/src/main/java/io/helidon/http/http2/Http2Headers.java index 62c9742a993..87c9537fc56 100644 --- a/http/http2/src/main/java/io/helidon/http/http2/Http2Headers.java +++ b/http/http2/src/main/java/io/helidon/http/http2/Http2Headers.java @@ -453,7 +453,7 @@ public void write(DynamicTable table, Http2HuffmanEncoder huffman, BufferData gr } for (Header header : headers) { - String value = header.value(); + String value = header.get(); boolean shouldIndex = !header.changing(); boolean neverIndex = header.sensitive(); @@ -649,7 +649,7 @@ private static Http2Headers createFromWritable(WritableHeaders headers) { headers.remove(HeaderNames.HOST, it -> { if (!pseudoHeaders.hasAuthority()) { - pseudoHeaders.authority(it.value()); + pseudoHeaders.authority(it.get()); } }); @@ -689,7 +689,7 @@ the stream (see Section 5.3). Add one to the value to obtain a private static void removeFromHeadersAddToPseudo(WritableHeaders headers, Consumer valueConsumer, HeaderName pseudoHeader) { - headers.remove(pseudoHeader, it -> valueConsumer.accept(it.value())); + headers.remove(pseudoHeader, it -> valueConsumer.accept(it.get())); } private void writeHeader(Http2HuffmanEncoder huffman, DynamicTable table, diff --git a/http/http2/src/test/java/io/helidon/http/http2/Http2HeadersTest.java b/http/http2/src/test/java/io/helidon/http/http2/Http2HeadersTest.java index 1aa703f9337..f27d7d77eb5 100644 --- a/http/http2/src/test/java/io/helidon/http/http2/Http2HeadersTest.java +++ b/http/http2/src/test/java/io/helidon/http/http2/Http2HeadersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Oracle and/or its affiliates. + * Copyright (c) 2022, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ void testC_2_1() { DynamicTable dynamicTable = DynamicTable.create(Http2Settings.create()); Headers requestHeaders = headers(hexEncoded, dynamicTable).httpHeaders(); - assertThat(requestHeaders.get(HeaderNames.create("custom-key")).value(), is("custom-header")); + assertThat(requestHeaders.get(HeaderNames.create("custom-key")).get(), is("custom-header")); } BufferData data(String hexEncoded) { @@ -76,7 +76,7 @@ void testC_2_3() { DynamicTable dynamicTable = DynamicTable.create(Http2Settings.create()); Headers requestHeaders = headers(hexEncoded, dynamicTable).httpHeaders(); - assertThat(requestHeaders.get(HeaderNames.create("password")).value(), is("secret")); + assertThat(requestHeaders.get(HeaderNames.create("password")).get(), is("secret")); assertThat("Dynamic table should be empty", dynamicTable.currentTableSize(), is(0)); } @@ -124,7 +124,7 @@ void testC_3() { assertThat(http2Headers.scheme(), is("http")); assertThat(http2Headers.path(), is("/")); assertThat(http2Headers.authority(), is("www.example.com")); - assertThat(requestHeaders.get(HeaderNames.create("cache-control")).value(), is("no-cache")); + assertThat(requestHeaders.get(HeaderNames.create("cache-control")).get(), is("no-cache")); assertThat("Dynamic table should not be empty", dynamicTable.currentTableSize(), not(0)); @@ -145,7 +145,7 @@ void testC_3() { assertThat(http2Headers.scheme(), is("https")); assertThat(http2Headers.path(), is("/index.html")); assertThat(http2Headers.authority(), is("www.example.com")); - assertThat(requestHeaders.get(CUSTOM_HEADER_NAME).value(), is("custom-value")); + assertThat(requestHeaders.get(CUSTOM_HEADER_NAME).get(), is("custom-value")); assertThat("Dynamic table should not be empty", dynamicTable.currentTableSize(), not(0)); @@ -214,7 +214,7 @@ void testC_4() { assertThat(http2Headers.scheme(), is("http")); assertThat(http2Headers.path(), is("/")); assertThat(http2Headers.authority(), is("www.example.com")); - assertThat(requestHeaders.get(HeaderNames.create("cache-control")).value(), is("no-cache")); + assertThat(requestHeaders.get(HeaderNames.create("cache-control")).get(), is("no-cache")); assertThat("Dynamic table should not be empty", dynamicTable.currentTableSize(), not(0)); @@ -235,7 +235,7 @@ void testC_4() { assertThat(http2Headers.scheme(), is("https")); assertThat(http2Headers.path(), is("/index.html")); assertThat(http2Headers.authority(), is("www.example.com")); - assertThat(requestHeaders.get(CUSTOM_HEADER_NAME).value(), is("custom-value")); + assertThat(requestHeaders.get(CUSTOM_HEADER_NAME).get(), is("custom-value")); assertThat("Dynamic table should not be empty", dynamicTable.currentTableSize(), not(0)); diff --git a/http/media/multipart/src/main/java/io/helidon/http/media/multipart/ReadablePartAbstract.java b/http/media/multipart/src/main/java/io/helidon/http/media/multipart/ReadablePartAbstract.java index f1e6a1bcc27..11d53a8a469 100644 --- a/http/media/multipart/src/main/java/io/helidon/http/media/multipart/ReadablePartAbstract.java +++ b/http/media/multipart/src/main/java/io/helidon/http/media/multipart/ReadablePartAbstract.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Oracle and/or its affiliates. + * Copyright (c) 2022, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,7 +80,7 @@ public boolean hasEntity() { private void contentDisposition() { if (headers.contains(HeaderNames.CONTENT_DISPOSITION)) { - this.contentDisposition = ContentDisposition.parse(headers.get(HeaderNames.CONTENT_DISPOSITION).value()); + this.contentDisposition = ContentDisposition.parse(headers.get(HeaderNames.CONTENT_DISPOSITION).get()); } else { this.contentDisposition = ContentDisposition.empty(); } diff --git a/integrations/common/rest/src/test/java/io/helidon/integrations/common/rest/RestApiTest.java b/integrations/common/rest/src/test/java/io/helidon/integrations/common/rest/RestApiTest.java index 145812c4fff..32165b38c9d 100644 --- a/integrations/common/rest/src/test/java/io/helidon/integrations/common/rest/RestApiTest.java +++ b/integrations/common/rest/src/test/java/io/helidon/integrations/common/rest/RestApiTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023 Oracle and/or its affiliates. + * Copyright (c) 2021, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -158,7 +158,7 @@ private JsonObjectBuilder common(ServerRequest req) { ServerRequestHeaders headers = req.headers(); if (headers.size() > 0) { JsonObjectBuilder headersBuilder = JSON.createObjectBuilder(); - headers.forEach(header -> headersBuilder.add(header.name(), header.value())); + headers.forEach(header -> headersBuilder.add(header.name(), header.get())); objectBuilder.add("headers", headersBuilder); } diff --git a/webclient/http1/src/main/java/io/helidon/webclient/http1/Http1CallChainBase.java b/webclient/http1/src/main/java/io/helidon/webclient/http1/Http1CallChainBase.java index bd7e0db61cc..efc20d457d2 100644 --- a/webclient/http1/src/main/java/io/helidon/webclient/http1/Http1CallChainBase.java +++ b/webclient/http1/src/main/java/io/helidon/webclient/http1/Http1CallChainBase.java @@ -250,7 +250,7 @@ private static InputStream inputStream(HttpClientConfig clientConfig, ContentDecoder decoder; if (encodingSupport.contentDecodingEnabled() && responseHeaders.contains(HeaderNames.CONTENT_ENCODING)) { - String contentEncoding = responseHeaders.get(HeaderNames.CONTENT_ENCODING).value(); + String contentEncoding = responseHeaders.get(HeaderNames.CONTENT_ENCODING).get(); if (encodingSupport.contentDecodingSupported(contentEncoding)) { decoder = encodingSupport.decoder(contentEncoding); } else { diff --git a/webclient/http1/src/main/java/io/helidon/webclient/http1/Http1CallOutputStreamChain.java b/webclient/http1/src/main/java/io/helidon/webclient/http1/Http1CallOutputStreamChain.java index 78fb1206a7f..1532f9d4777 100644 --- a/webclient/http1/src/main/java/io/helidon/webclient/http1/Http1CallOutputStreamChain.java +++ b/webclient/http1/src/main/java/io/helidon/webclient/http1/Http1CallOutputStreamChain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Oracle and/or its affiliates. + * Copyright (c) 2023, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -130,7 +130,7 @@ WebClientServiceResponse doProceed(ClientConnection connection, if (originalRequest().followRedirects() && RedirectionProcessor.redirectionStatusCode(responseStatus)) { checkRedirectHeaders(responseHeaders); - URI newUri = URI.create(responseHeaders.get(HeaderNames.LOCATION).value()); + URI newUri = URI.create(responseHeaders.get(HeaderNames.LOCATION).get()); ClientUri redirectUri = ClientUri.create(newUri); if (newUri.getHost() == null) { UriInfo resolvedUri = cos.lastRequest.resolvedUri(); @@ -440,7 +440,7 @@ private void sendPrologueAndHeader() { } private void redirect(Status lastStatus, WritableHeaders headerValues) { - String redirectedUri = headerValues.get(HeaderNames.LOCATION).value(); + String redirectedUri = headerValues.get(HeaderNames.LOCATION).get(); ClientUri lastUri = originalRequest.uri(); Method method; boolean sendEntity; @@ -492,7 +492,7 @@ private void redirect(Status lastStatus, WritableHeaders headerValues) { method = Method.GET; sendEntity = false; } - redirectedUri = response.headers().get(HeaderNames.LOCATION).value(); + redirectedUri = response.headers().get(HeaderNames.LOCATION).get(); } } else { if (!sendEntity) { diff --git a/webclient/http1/src/main/java/io/helidon/webclient/http1/RedirectionProcessor.java b/webclient/http1/src/main/java/io/helidon/webclient/http1/RedirectionProcessor.java index 0ea7b39d733..4ae672c6dcc 100644 --- a/webclient/http1/src/main/java/io/helidon/webclient/http1/RedirectionProcessor.java +++ b/webclient/http1/src/main/java/io/helidon/webclient/http1/RedirectionProcessor.java @@ -56,7 +56,7 @@ static Http1ClientResponseImpl invokeWithFollowRedirects(Http1ClientRequestImpl + " header present in the response! " + "It is not clear where to redirect."); } - String redirectedUri = clientResponse.headers().get(HeaderNames.LOCATION).value(); + String redirectedUri = clientResponse.headers().get(HeaderNames.LOCATION).get(); URI newUri = URI.create(redirectedUri); ClientUri redirectUri = ClientUri.create(newUri); diff --git a/webclient/websocket/src/main/java/io/helidon/webclient/websocket/WsClientImpl.java b/webclient/websocket/src/main/java/io/helidon/webclient/websocket/WsClientImpl.java index 63c3a58615c..ee09ea95835 100644 --- a/webclient/websocket/src/main/java/io/helidon/webclient/websocket/WsClientImpl.java +++ b/webclient/websocket/src/main/java/io/helidon/webclient/websocket/WsClientImpl.java @@ -142,14 +142,14 @@ public void connect(URI uri, WsListener listener) { + responseHeaders); } ClientConnection connection = upgradeResponse.connection(); - String secWsAccept = responseHeaders.get(HEADER_WS_ACCEPT).value(); + String secWsAccept = responseHeaders.get(HEADER_WS_ACCEPT).get(); if (!hash(connection.helidonSocket(), secWsKey).equals(secWsAccept)) { throw new WsClientException("Failed to upgrade to WebSocket, expected valid secWsKey. Headers: " + responseHeaders); } // we are upgraded, let's switch to web socket if (headers.contains(HEADER_WS_PROTOCOL)) { - session = new ClientWsConnection(connection, listener, headers.get(HEADER_WS_PROTOCOL).value()); + session = new ClientWsConnection(connection, listener, headers.get(HEADER_WS_PROTOCOL).get()); } else { session = new ClientWsConnection(connection, listener); } diff --git a/webserver/cors/src/test/java/io/helidon/webserver/cors/AbstractCorsTest.java b/webserver/cors/src/test/java/io/helidon/webserver/cors/AbstractCorsTest.java index d484aca0fc4..b2d3e146d35 100644 --- a/webserver/cors/src/test/java/io/helidon/webserver/cors/AbstractCorsTest.java +++ b/webserver/cors/src/test/java/io/helidon/webserver/cors/AbstractCorsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023 Oracle and/or its affiliates. + * Copyright (c) 2020, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -178,11 +178,11 @@ void test2PreFlightAllowedHeaders1() { assertThat(response.status(), is(Status.OK_200)); assertThat(response.headers() - .get(ACCESS_CONTROL_ALLOW_ORIGIN).value(), is(fooOrigin())); + .get(ACCESS_CONTROL_ALLOW_ORIGIN).get(), is(fooOrigin())); assertThat(response.headers() - .get(ACCESS_CONTROL_ALLOW_CREDENTIALS).value(), is("true")); + .get(ACCESS_CONTROL_ALLOW_CREDENTIALS).get(), is("true")); assertThat(response.headers() - .get(ACCESS_CONTROL_ALLOW_METHODS).value(), is("PUT")); + .get(ACCESS_CONTROL_ALLOW_METHODS).get(), is("PUT")); assertThat(response.headers() .get(ACCESS_CONTROL_ALLOW_HEADERS).values(), containsString(fooHeader())); assertThat(response.headers(), noHeader(ACCESS_CONTROL_MAX_AGE)); @@ -204,8 +204,8 @@ void test2PreFlightAllowedHeaders2() { assertThat(response.headers(), hasHeader(ACCESS_CONTROL_ALLOW_ORIGIN, "http://foo.bar")); assertThat(response.headers(), hasHeader(ACCESS_CONTROL_ALLOW_CREDENTIALS, "true")); assertThat(response.headers(), hasHeader(ACCESS_CONTROL_ALLOW_METHODS, "PUT")); - assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_HEADERS).value(), containsString("X-foo")); - assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_HEADERS).value(), containsString("X-bar")); + assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_HEADERS).get(), containsString("X-foo")); + assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_HEADERS).get(), containsString("X-bar")); assertThat(response.headers(), noHeader(ACCESS_CONTROL_MAX_AGE)); } } @@ -226,8 +226,8 @@ void test2PreFlightAllowedHeaders3() { assertThat(response.headers(), hasHeader(ACCESS_CONTROL_ALLOW_ORIGIN, "http://foo.bar")); assertThat(response.headers(), hasHeader(ACCESS_CONTROL_ALLOW_CREDENTIALS, "true")); assertThat(response.headers(), hasHeader(ACCESS_CONTROL_ALLOW_METHODS, "PUT")); - assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_HEADERS).value(), containsString("X-foo")); - assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_HEADERS).value(), containsString("X-bar")); + assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_HEADERS).get(), containsString("X-foo")); + assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_HEADERS).get(), containsString("X-bar")); assertThat(response.headers(), noHeader(ACCESS_CONTROL_MAX_AGE)); } } diff --git a/webserver/webserver/src/main/java/io/helidon/webserver/http1/Http1ServerRequest.java b/webserver/webserver/src/main/java/io/helidon/webserver/http1/Http1ServerRequest.java index 84a7a1e5e9c..86a29e7a8de 100644 --- a/webserver/webserver/src/main/java/io/helidon/webserver/http1/Http1ServerRequest.java +++ b/webserver/webserver/src/main/java/io/helidon/webserver/http1/Http1ServerRequest.java @@ -182,7 +182,7 @@ public PeerInfo localPeer() { @Override public String authority() { - return headers.get(HeaderNames.HOST).value(); + return headers.get(HeaderNames.HOST).get(); } @Override diff --git a/webserver/websocket/src/main/java/io/helidon/webserver/websocket/WsUpgrader.java b/webserver/websocket/src/main/java/io/helidon/webserver/websocket/WsUpgrader.java index 71f21ca49a0..997e29518f4 100644 --- a/webserver/websocket/src/main/java/io/helidon/webserver/websocket/WsUpgrader.java +++ b/webserver/websocket/src/main/java/io/helidon/webserver/websocket/WsUpgrader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Oracle and/or its affiliates. + * Copyright (c) 2022, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -124,7 +124,7 @@ public String supportedProtocol() { public ServerConnection upgrade(ConnectionContext ctx, HttpPrologue prologue, WritableHeaders headers) { String wsKey; if (headers.contains(WS_KEY)) { - wsKey = headers.get(WS_KEY).value(); + wsKey = headers.get(WS_KEY).get(); } else { // this header is required return null; @@ -132,7 +132,7 @@ public ServerConnection upgrade(ConnectionContext ctx, HttpPrologue prologue, Wr // protocol version String version; if (headers.contains(WS_VERSION)) { - version = headers.get(WS_VERSION).value(); + version = headers.get(WS_VERSION).get(); } else { version = SUPPORTED_VERSION; } @@ -156,7 +156,7 @@ public ServerConnection upgrade(ConnectionContext ctx, HttpPrologue prologue, Wr if (!anyOrigin()) { if (headers.contains(HeaderNames.ORIGIN)) { - String origin = headers.get(HeaderNames.ORIGIN).value(); + String origin = headers.get(HeaderNames.ORIGIN).get(); if (!origins().contains(origin)) { throw RequestException.builder() .message("Invalid Origin")