Skip to content

Commit

Permalink
Remove Constant from HttpClient (#17814)
Browse files Browse the repository at this point in the history
  • Loading branch information
alzimmermsft authored Nov 25, 2020
1 parent c0827b3 commit c67d58b
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Mono<HttpResponse> send(HttpRequest request) {

@Override
public Mono<HttpResponse> send(HttpRequest request, Context context) {
boolean eagerlyReadResponse = (boolean) context.getData(EAGERLY_READ_RESPONSE_CONTEXT_KEY).orElse(false);
boolean eagerlyReadResponse = (boolean) context.getData("azure-eagerly-read-response").orElse(false);

return toJdkHttpRequest(request)
.flatMap(jdkRequest -> Mono.fromCompletionStage(jdkHttpClient.sendAsync(jdkRequest, ofPublisher()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Mono<HttpResponse> send(HttpRequest request, Context context) {
Objects.requireNonNull(request.getUrl(), "'request.getUrl()' cannot be null.");
Objects.requireNonNull(request.getUrl().getProtocol(), "'request.getUrl().getProtocol()' cannot be null.");

boolean eagerlyReadResponse = (boolean) context.getData(EAGERLY_READ_RESPONSE_CONTEXT_KEY).orElse(false);
boolean eagerlyReadResponse = (boolean) context.getData("azure-eagerly-read-response").orElse(false);

return nettyClient
.request(HttpMethod.valueOf(request.getHttpMethod().toString()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Mono<HttpResponse> send(HttpRequest request) {

@Override
public Mono<HttpResponse> send(HttpRequest request, Context context) {
boolean eagerlyReadResponse = (boolean) context.getData(EAGERLY_READ_RESPONSE_CONTEXT_KEY).orElse(false);
boolean eagerlyReadResponse = (boolean) context.getData("azure-eagerly-read-response").orElse(false);

return Mono.create(sink -> sink.onRequest(value -> {
// Using MonoSink::onRequest for back pressure support.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
* A generic interface for sending HTTP requests and getting responses.
*/
public interface HttpClient {
/**
* Key for {@link Context} where the value is a boolean flag that indicates whether the {@link HttpResponse} body
* should be eagerly read and buffered into memory.
*/
String EAGERLY_READ_RESPONSE_CONTEXT_KEY = "azure-eagerly-read-response";

/**
* Send the provided request asynchronously.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import java.util.function.Function;
import java.util.function.Supplier;

import static com.azure.core.http.HttpClient.EAGERLY_READ_RESPONSE_CONTEXT_KEY;
import static com.azure.core.implementation.serializer.HttpResponseBodyDecoder.isReturnTypeDecodable;

/**
Expand Down Expand Up @@ -124,7 +123,7 @@ public Object invoke(Object proxy, final Method method, Object[] args) {
final HttpRequest request = createHttpRequest(methodParser, args);
Context context = methodParser.setContext(args)
.addData("caller-method", methodParser.getFullyQualifiedMethodName())
.addData(EAGERLY_READ_RESPONSE_CONTEXT_KEY, isReturnTypeDecodable(methodParser.getReturnType()));
.addData("azure-eagerly-read-response", isReturnTypeDecodable(methodParser.getReturnType()));
context = startTracingSpan(method, context);

if (request.getBody() != null) {
Expand Down

0 comments on commit c67d58b

Please sign in to comment.