|
8 | 8 | import java.util.Collection; |
9 | 9 | import java.util.Comparator; |
10 | 10 | import java.util.List; |
11 | | -import java.util.Locale; |
12 | 11 | import java.util.TreeSet; |
13 | 12 | import software.amazon.smithy.aws.traits.ServiceTrait; |
14 | 13 | import software.amazon.smithy.codegen.core.Symbol; |
15 | | -import software.amazon.smithy.model.knowledge.EventStreamIndex; |
16 | 14 | import software.amazon.smithy.model.knowledge.ServiceIndex; |
17 | 15 | import software.amazon.smithy.model.knowledge.TopDownIndex; |
18 | | -import software.amazon.smithy.model.node.ArrayNode; |
19 | | -import software.amazon.smithy.model.node.StringNode; |
20 | | -import software.amazon.smithy.model.shapes.OperationShape; |
21 | 16 | import software.amazon.smithy.python.codegen.CodegenUtils; |
22 | 17 | import software.amazon.smithy.python.codegen.ConfigProperty; |
23 | 18 | import software.amazon.smithy.python.codegen.GenerationContext; |
@@ -154,57 +149,20 @@ private static List<ConfigProperty> getProtocolProperties(GenerationContext cont |
154 | 149 |
|
155 | 150 | if (context.applicationProtocol().isHttpProtocol()) { |
156 | 151 | properties.addAll(HTTP_PROPERTIES); |
157 | | - if (usesHttp2(context)) { |
158 | | - transportBuilder |
159 | | - .initialize(writer -> { |
160 | | - writer.addDependency(SmithyPythonDependency.SMITHY_HTTP.withOptionalDependencies("awscrt")); |
161 | | - writer.write("self.transport = transport or $T()", |
162 | | - RuntimeTypes.AWS_CRT_HTTP_CLIENT); |
163 | | - }); |
164 | | - |
165 | | - } else { |
166 | | - transportBuilder |
167 | | - .initialize(writer -> { |
168 | | - writer.addDependency( |
169 | | - SmithyPythonDependency.SMITHY_HTTP.withOptionalDependencies("aiohttp")); |
170 | | - writer.write("self.transport = transport or $T()", |
171 | | - RuntimeTypes.AIOHTTP_CLIENT); |
172 | | - }); |
173 | | - } |
| 152 | + transportBuilder |
| 153 | + .initialize(writer -> { |
| 154 | + writer.addDependency( |
| 155 | + SmithyPythonDependency.SMITHY_HTTP.withOptionalDependencies("aiohttp")); |
| 156 | + writer.write("self.transport = transport or $T()", |
| 157 | + RuntimeTypes.AIOHTTP_CLIENT); |
| 158 | + }); |
174 | 159 | } |
175 | 160 |
|
176 | 161 | properties.add(protocolBuilder.build()); |
177 | 162 | properties.add(transportBuilder.build()); |
178 | 163 | return properties; |
179 | 164 | } |
180 | 165 |
|
181 | | - private static boolean usesHttp2(GenerationContext context) { |
182 | | - var configuration = context.applicationProtocol().configuration(); |
183 | | - var httpVersions = configuration.getArrayMember("http") |
184 | | - .orElse(ArrayNode.arrayNode()) |
185 | | - .getElementsAs(StringNode.class) |
186 | | - .stream() |
187 | | - .map(node -> node.getValue().toLowerCase(Locale.ENGLISH)) |
188 | | - .toList(); |
189 | | - |
190 | | - // An explicit http2 configuration |
191 | | - if (httpVersions.contains("h2")) { |
192 | | - return true; |
193 | | - } |
194 | | - |
195 | | - // enable CRT/http2 client if the service supports any event streams (single or bi-directional) |
196 | | - // TODO: Long term, only bi-directional evenstreams strictly require h2 |
197 | | - var eventIndex = EventStreamIndex.of(context.model()); |
198 | | - var topDownIndex = TopDownIndex.of(context.model()); |
199 | | - for (OperationShape operation : topDownIndex.getContainedOperations(context.settings().service())) { |
200 | | - if (eventIndex.getInputInfo(operation).isPresent() || eventIndex.getOutputInfo(operation).isPresent()) { |
201 | | - return true; |
202 | | - } |
203 | | - } |
204 | | - |
205 | | - return false; |
206 | | - } |
207 | | - |
208 | 166 | private static List<ConfigProperty> getAuthProperties(GenerationContext context) { |
209 | 167 | return List.of( |
210 | 168 | ConfigProperty.builder() |
|
0 commit comments