unknowntpo commented on code in PR #8614:
URL: https://github.com/apache/ozone/pull/8614#discussion_r2144195390
##########
hadoop-ozone/httpfsgateway/src/main/java/org/apache/ozone/fs/http/server/CheckUploadContentTypeFilter.java:
##########
@@ -93,10 +94,20 @@ public void doFilter(ServletRequest request,
ServletResponse response,
if (contentTypeOK) {
chain.doFilter(httpReq, httpRes);
} else {
- httpRes.sendError(HttpServletResponse.SC_BAD_REQUEST,
- "Data upload requests must have content-type set to '"
+
- HttpFSConstants.UPLOAD_CONTENT_TYPE + "'");
+ httpRes.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ httpRes.setContentType("application/json");
+ httpRes.setCharacterEncoding("UTF-8");
+ String errorMessage = "Data upload requests must have content-type set
to '" +
+ HttpFSConstants.UPLOAD_CONTENT_TYPE + "'";
+
+ // Create JSON response
+ String jsonResponse = "{\"error\":\"" + errorMessage + "\"}";
+
+ PrintWriter writer = httpRes.getWriter();
+ writer.write(jsonResponse);
+ writer.flush();
+ writer.close();
Review Comment:
I use JsonUtil to do this, which use Jackson under the hood.
--
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]