forked from helidon-io/helidon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTTP/2.0 Client trailers support helidon-io#6544 (helidon-io#7516)
- Loading branch information
Showing
19 changed files
with
573 additions
and
115 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
http/http/src/main/java/io/helidon/http/ClientResponseTrailers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2023 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://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 io.helidon.http; | ||
|
||
/** | ||
* HTTP Trailer headers of a client response. | ||
*/ | ||
public interface ClientResponseTrailers extends io.helidon.http.Headers { | ||
|
||
/** | ||
* Create new trailers from headers future. | ||
* | ||
* @param headers trailer headers | ||
* @return new client trailers from headers future | ||
*/ | ||
static ClientResponseTrailers create(io.helidon.http.Headers headers) { | ||
return new ClientResponseTrailersImpl(headers); | ||
} | ||
|
||
/** | ||
* Create new empty trailers. | ||
* | ||
* @return new empty client trailers | ||
*/ | ||
static ClientResponseTrailers create() { | ||
return new ClientResponseTrailersImpl(); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
http/http/src/main/java/io/helidon/http/ClientResponseTrailersImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) 2023 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://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 io.helidon.http; | ||
|
||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.function.Supplier; | ||
|
||
class ClientResponseTrailersImpl implements ClientResponseTrailers { | ||
private static final Headers EMPTY_TRAILERS = WritableHeaders.create(); | ||
private final Headers trailers; | ||
|
||
ClientResponseTrailersImpl(Headers trailers) { | ||
this.trailers = trailers; | ||
} | ||
|
||
ClientResponseTrailersImpl() { | ||
this.trailers = EMPTY_TRAILERS; | ||
} | ||
|
||
@Override | ||
public List<String> all(HeaderName name, Supplier<List<String>> defaultSupplier) { | ||
return trailers.all(name, defaultSupplier); | ||
} | ||
|
||
@Override | ||
public boolean contains(HeaderName name) { | ||
return trailers.contains(name); | ||
} | ||
|
||
@Override | ||
public boolean contains(Header value) { | ||
return trailers.contains(value); | ||
} | ||
|
||
@Override | ||
public Header get(HeaderName name) { | ||
return trailers.get(name); | ||
} | ||
|
||
@Override | ||
public int size() { | ||
return trailers.size(); | ||
} | ||
|
||
@Override | ||
public List<HttpMediaType> acceptedTypes() { | ||
return trailers.acceptedTypes(); | ||
} | ||
|
||
@Override | ||
public Iterator<Header> iterator() { | ||
return trailers.iterator(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
webclient/api/src/main/java/io/helidon/webclient/api/WebClientServiceResponseDecorator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2023 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://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 io.helidon.webclient.api; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
import io.helidon.builder.api.Prototype; | ||
import io.helidon.http.ClientResponseTrailers; | ||
|
||
class WebClientServiceResponseDecorator implements Prototype.BuilderDecorator<WebClientServiceResponse.BuilderBase<?, ?>> { | ||
@Override | ||
public void decorate(WebClientServiceResponse.BuilderBase<?, ?> target) { | ||
if (target.trailers().isEmpty()) { | ||
// Empty trailers by default | ||
target.trailers(CompletableFuture.completedFuture(ClientResponseTrailers.create())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.