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

Support http OPTIONS #802

Merged
merged 3 commits into from
May 29, 2020
Merged
Changes from 1 commit
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
@@ -375,6 +375,7 @@ private static boolean safeToRetry(HttpMethod httpMethod) {
switch (httpMethod) {
case GET:
case HEAD:
case OPTIONS:
return true;
case PUT:
case DELETE:
Original file line number Diff line number Diff line change
@@ -93,6 +93,11 @@ public ListenableFuture<Response> execute(Endpoint endpoint, Request request) {
case PATCH:
okRequest = okRequest.patch(toOkHttpBody(request.body()));
break;
case OPTIONS:
Preconditions.checkArgument(
!request.body().isPresent(), "OPTIONS endpoints must not have a request body");
okRequest = okRequest.method("OPTIONS", null);
break;
}

// Fill headers
Original file line number Diff line number Diff line change
@@ -24,4 +24,5 @@ public enum HttpMethod {
PATCH,
POST,
PUT,
OPTIONS
}
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
import com.google.common.util.concurrent.MoreExecutors;
import com.palantir.dialogue.Channel;
import com.palantir.dialogue.Endpoint;
import com.palantir.dialogue.HttpMethod;
import com.palantir.dialogue.Request;
import com.palantir.dialogue.Response;
import com.palantir.dialogue.TestResponse;
@@ -74,6 +75,10 @@ public static Builder builder() {

@Override
public ListenableFuture<Response> execute(Endpoint endpoint, Request request) {
if (endpoint.httpMethod() == HttpMethod.OPTIONS) {
return Futures.immediateFuture(new TestResponse().code(204));
}

Meter perEndpointRequests = MetricNames.requestMeter(simulation.taggedMetrics(), serverName, endpoint);

activeRequests.inc();