Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Constant from HttpClient #17814

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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