FrankChen021 commented on code in PR #17937:
URL: https://github.com/apache/druid/pull/17937#discussion_r2050635704
##########
sql/src/main/java/org/apache/druid/sql/http/SqlQuery.java:
##########
@@ -200,4 +209,44 @@ public SqlQuery withQueryContext(Map<String, Object>
newContext)
{
return new SqlQuery(query, resultFormat, header, typesHeader,
sqlTypesHeader, newContext, parameters);
}
+
+ /**
+ * For BROKERs to use.
+ *
+ * Brokers use com.sun.jersey upon Jetty for RESTful API, however jersey
internally has sepcial handling for x-www-form-urlencoded,
+ * it's not able to get the data from the stream of HttpServletRequest for
such content type.
+ * So we use HttpContext to get the request entity/string instead of using
HttpServletRequest.
+ */
+ public static SqlQuery from(HttpContext httpContext)
+ {
+ MediaType contentType = httpContext.getRequest().getMediaType();
+ if (MediaType.APPLICATION_JSON_TYPE.isCompatible(contentType)) {
+ return httpContext.getRequest().getEntity(SqlQuery.class);
+ } else {
+ // Treats the whole HTTP body as a SQL
+ String sql = httpContext.getRequest().getEntity(String.class);
+ if
(MediaType.APPLICATION_FORM_URLENCODED_TYPE.isCompatible(contentType)) {
Review Comment:
no need
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]