You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "zeroflag (via GitHub)" <gi...@apache.org> on 2023/06/07 08:23:48 UTC

[GitHub] [hadoop] zeroflag commented on a diff in pull request #5721: HDFS-17040 - WebHDFS UI should set content type to application/octet-stream when uploading a file

zeroflag commented on code in PR #5721:
URL: https://github.com/apache/hadoop/pull/5721#discussion_r1221138670


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.js:
##########
@@ -518,7 +518,8 @@
             url: url,
             data: file.file,
             processData: false,
-            crossDomain: true
+            crossDomain: true,
+            contentType: 'application/octet-stream'

Review Comment:
   @szetszwo Yes, this is the JS code running in the client browser. By default the contentType is set to `application/x-www-form-urlencoded` now it's explicitly set to `application/octet-stream`.
   
   However I a found a problem when testing with newer browsers with CORS enabled. It works when I try it via Knox or with a browser where CORS is disabled.
   
   But in new browsers with Cross-Origin Resource Sharing policy prevents changing the contentType since it's not included in the `Access-Control-Allow-Headers` header. Only the accept header is included in `Access-Control-Allow-Headers`.
   
   ```
   Access-Control-Allow-Headers: Accept
   Access-Control-Allow-Methods: PUT
   Access-Control-Allow-Origin: *
   ``` 
   
   The CrossOriginFilter contains the content type so I don't know why I only see `Accept`
   
    https://github.com/apache/hadoop/blob/9de13f879af66a211b098166fd423b6900fc730d/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/http/CrossOriginFilter.java#L74
   



-- 
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: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org