Skip to content

Commit 4a1758b

Browse files
author
WenChao Zhu
committed
YARN-11691. Add HTTP POST method to yarn web proxy servlet.
1 parent daafc8a commit 4a1758b

File tree

1 file changed

+14
-0
lines changed
  • hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy

1 file changed

+14
-0
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
import org.apache.http.client.HttpClient;
7070
import org.apache.http.client.config.RequestConfig;
7171
import org.apache.http.client.methods.HttpGet;
72+
import org.apache.http.client.methods.HttpPost;
7273
import org.apache.http.client.methods.HttpPut;
7374
import org.apache.http.client.methods.HttpRequestBase;
7475
import org.apache.http.client.utils.URLEncodedUtils;
@@ -295,6 +296,19 @@ private void proxyLink(final HttpServletRequest req,
295296
}
296297

297298
((HttpPut) base).setEntity(new StringEntity(sb.toString()));
299+
} else if (method.equals(HTTP.POST)){
300+
base = new HttpPost(link);
301+
302+
StringBuilder sb = new StringBuilder();
303+
BufferedReader reader =
304+
new BufferedReader(
305+
new InputStreamReader(req.getInputStream(), "UTF-8"));
306+
String line;
307+
while ((line = reader.readLine()) != null) {
308+
sb.append(line);
309+
}
310+
311+
((HttpPost) base).setEntity(new StringEntity(sb.toString()));
298312
} else {
299313
resp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
300314
return;

0 commit comments

Comments
 (0)