/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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 software.amazon.awssdk.http; import static java.util.Collections.singletonList; import java.io.InputStream; import java.util.List; import java.util.Map; import java.util.Optional; import software.amazon.awssdk.annotations.Immutable; import software.amazon.awssdk.annotations.SdkProtectedApi; /** * An immutable HTTP response with a possible HTTP body. * *
All implementations of this interface MUST be immutable. Instead of implementing this interface, consider using * {@link #builder()} to create an instance.
*/ @SdkProtectedApi @Immutable public interface SdkHttpFullResponse extends SdkHttpResponse { /** * @return Builder instance to construct a {@link DefaultSdkHttpFullResponse}. */ static Builder builder() { return new DefaultSdkHttpFullResponse.Builder(); } @Override Builder toBuilder(); /** * Returns the optional stream containing the payload data returned by the service. Note: an {@link AbortableInputStream} * is returned instead of an {@link InputStream}. This allows the stream to be aborted before all content is read, which * usually means destroying the underlying HTTP connection. This may be implemented differently in other HTTP implementations. * *When the response does not include payload data, this will return {@link Optional#empty()}.
* * @return The optional stream containing the payload data included in this response, or empty if there is no payload. */ OptionalThis completely OVERRIDES any values already configured with this header name in the builder.
* * @param headerName The name of the header to add (eg. "Host") * @param headerValue The value for the header */ @Override default Builder putHeader(String headerName, String headerValue) { return putHeader(headerName, singletonList(headerValue)); } /** * Add a single header with multiple values to be included in the created HTTP response. * *This completely OVERRIDES any values already configured with this header name in the builder.
* * @param headerName The name of the header to add * @param headerValues The values for the header */ @Override Builder putHeader(String headerName, ListThis will ADD the value to any existing values already configured with this header name in * the builder.
* * @param headerName The name of the header to add * @param headerValue The value for the header */ @Override Builder appendHeader(String headerName, String headerValue); /** * Configure an {@link SdkHttpResponse#headers()} to be used in the created HTTP response. This is not validated * until the http response is created. This overrides any values currently configured in the builder. */ @Override Builder headers(MapImplementers should implement the abort method on the input stream to drop all remaining content with the service. * This is usually done by closing the service connection.
*/ Builder content(AbortableInputStream content); @Override SdkHttpFullResponse build(); } }