You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@livy.apache.org by "Nilesh Rathi (Jira)" <ji...@apache.org> on 2026/08/05 07:55:00 UTC
[jira] [Assigned] (LIVY-1062) Handle HTTP 307 redirects for POST/DELETE in LivyConnection
[ https://issues.apache.org/jira/browse/LIVY-1062?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Nilesh Rathi reassigned LIVY-1062:
----------------------------------
Assignee: (was: Nilesh Rathi)
> Handle HTTP 307 redirects for POST/DELETE in LivyConnection
> -----------------------------------------------------------
>
> Key: LIVY-1062
> URL: https://issues.apache.org/jira/browse/LIVY-1062
> Project: Livy
> Issue Type: Bug
> Reporter: Nilesh Rathi
> Priority: Major
> Time Spent: 40m
> Remaining Estimate: 0h
>
> The Livy Java HTTP client ({{{}LivyConnection{}}} in {{{}client-http{}}}) does not handle HTTP {{307 Temporary Redirect}} for {{POST}} and {{DELETE}} requests. Apache HttpClient does not automatically follow redirects for non-idempotent methods, and {{LivyConnection.sendRequest()}} treats any non-200 response as a fatal error.
> h3. Problem
> When a {{POST}} (session creation, job submission) or {{DELETE}} (session/job cancellation) request receives HTTP 307, {{LivyConnection}} does not follow the redirect and throws {{{}IOException{}}}. This affects the Java/Scala Job API, which relies heavily on POST and DELETE.
> h3. Root Cause
> In {{{}client-http/src/main/java/org/apache/livy/client/http/LivyConnection.java{}}}, {{sendRequest()}} only accepts {{HTTP 200 (SC_OK)}} as success. Any other status code (including {{{}307 Temporary Redirect{}}}) causes an {{{}IOException{}}}:
> {code:java}
> int status = (res.getStatusLine().getStatusCode() / 100) * 100;
> if (status == HttpStatus.SC_OK) {
> // success
> } else {
> throw new IOException(String.format("%s: %s", res.getStatusLine().getReasonPhrase(), error));
> }
> {code}
> Apache HttpClient follows redirects for {{GET}} but not for {{POST}} or {{{}DELETE{}}}.
> h3. Proposed fix
> Handle 307 in {{{}sendRequest(){}}}: validate {{{}Location{}}}, consume the redirect response entity, retry the request to the redirect URL (limit redirects to avoid loops). No behavior change when the server returns 200.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)