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 7bc78ab commit e47c11a
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
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.params.ClientPNames;
Expand Down Expand Up @@ -207,6 +208,19 @@ private static 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 e47c11a

Please sign in to comment.