Claus Ibsen created HTTPCLIENT-2390: ---------------------------------------
Summary: Allow to control HTTP redirect 301/302 to not change POST to GET Key: HTTPCLIENT-2390 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2390 Project: HttpComponents HttpClient Issue Type: Improvement Affects Versions: 5.4.4 Reporter: Claus Ibsen At Apache Camel we have users reporting a situation with using a graphql service that returns a 301 redirect and this causes the call to fail because the payload is removed due to POST becomes GET. This is correct according to HTTP spec. But often the real world is "different" and it would be good if there was an option or some enhanced API in RedirectStrategy so end users can handle this. If you look at the source code in org/apache/httpcomponents/client5/httpclient5/5.4.4/httpclient5-5.4.4-sources.jar!/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java:149 You can see how status 301/302 is forced to change POST to GET. This is what would be good if there was some flag or API to decide not to do that. The Apache Camel use-case it is v2: rest("/v2/swapi-graphql/all-films").get() .produces("application/json") .to("direct:swapi-graphql-all-films2"); from("direct:swapi-graphql-all-films2") .setBody(constant("\{ allFilms { films { title director releaseDate } } }")) .to("graphql://[https://swapi-graphql.netlify.app/.netlify/functions/index]") .convertBodyTo(String.class); The reason for the failure is interesting: 1. GraphQL component constructs POST and invokes HTTP 2. netlify's index URL returns 301 with /graphql - and that forces POST to be changed to GET by underlying http client. looking at HTTP spec - it should have been 308 [https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/308] - but haven't seen 308 adopted widely. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org