Skip to content

Commit

Permalink
YARN-11691. Add HTTP POST method to yarn web proxy servlet.
Browse files Browse the repository at this point in the history
  • Loading branch information
WenChao Zhu committed Apr 29, 2024
1 parent daafc8a commit 4a1758b
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.utils.URLEncodedUtils;
Expand Down Expand Up @@ -295,6 +296,19 @@ private void proxyLink(final HttpServletRequest req,
}

((HttpPut) base).setEntity(new StringEntity(sb.toString()));
} else if (method.equals(HTTP.POST)){
base = new HttpPost(link);

StringBuilder sb = new StringBuilder();
BufferedReader reader =
new BufferedReader(
new InputStreamReader(req.getInputStream(), "UTF-8"));
String line;
while ((line = reader.readLine()) != null) {
sb.append(line);
}

((HttpPost) base).setEntity(new StringEntity(sb.toString()));
} else {
resp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
return;
Expand Down

0 comments on commit 4a1758b

Please sign in to comment.