1 /* 2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"). 5 * You may not use this file except in compliance with the License. 6 * A copy of the License is located at 7 * 8 * http://aws.amazon.com/apache2.0 9 * 10 * or in the "license" file accompanying this file. This file is distributed 11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 * express or implied. See the License for the specific language governing 13 * permissions and limitations under the License. 14 */ 15 16 package software.amazon.awssdk.http; 17 18 import software.amazon.awssdk.annotations.SdkInternalApi; 19 import software.amazon.awssdk.annotations.SdkProtectedApi; 20 21 /** 22 * Container for extra dependencies needed during execution of a request. 23 */ 24 @SdkProtectedApi 25 public class SdkRequestContext { 26 private final boolean isFullDuplex; 27 SdkRequestContext(Builder builder)28 private SdkRequestContext(Builder builder) { 29 this.isFullDuplex = builder.isFullDuplex; 30 } 31 32 /** 33 * @return Builder instance to construct a {@link SdkRequestContext}. 34 */ 35 @SdkInternalApi builder()36 public static Builder builder() { 37 return new Builder(); 38 } 39 40 /** 41 * Option to indicate if the request is for a full duplex operation ie., request and response are sent/received at the same 42 * time. 43 * This can be used to set http configuration like ReadTimeouts as soon as request has begin sending data instead of 44 * waiting for the entire request to be sent. 45 * 46 * @return True if the operation this request belongs to is full duplex. Otherwise false. 47 */ fullDuplex()48 public boolean fullDuplex() { 49 return isFullDuplex; 50 } 51 52 /** 53 * Builder for a {@link SdkRequestContext}. 54 */ 55 @SdkInternalApi 56 public static final class Builder { 57 private boolean isFullDuplex; 58 Builder()59 private Builder() { 60 } 61 fullDuplex()62 public boolean fullDuplex() { 63 return isFullDuplex; 64 } 65 fullDuplex(boolean fullDuplex)66 public Builder fullDuplex(boolean fullDuplex) { 67 isFullDuplex = fullDuplex; 68 return this; 69 } 70 71 /** 72 * @return An immutable {@link SdkRequestContext} object. 73 */ build()74 public SdkRequestContext build() { 75 return new SdkRequestContext(this); 76 } 77 } 78 } 79