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/06 10:05:16 UTC

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

zeroflag opened a new pull request, #5721:
URL: https://github.com/apache/hadoop/pull/5721

   ### Description of PR
   
   When uploading a file WebHDFS will set the content type to application/x-www-form-urlencoded, as this is the default used by jQuery
   
   This causes knox to urlencode the request body so that uploading a CVS file 1,2,3 will result 1%2C2%2C3.
   
   Instead of application/x-www-form-urlencoded I think the encoding should be set to application/octet-stream.
   
   ### How was this patch tested?
   
   Tested manually using webhdfs UI
   
   ### For code changes:
   
   content type is explicitly set to octet stream
   


-- 
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


[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

Posted by "zeroflag (via GitHub)" <gi...@apache.org>.
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


[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

Posted by "zeroflag (via GitHub)" <gi...@apache.org>.
zeroflag commented on code in PR #5721:
URL: https://github.com/apache/hadoop/pull/5721#discussion_r1221274841


##########
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:
   Yes I've seen that, but it wasn't overridden. Even if I explicitly added   
   
   ```xml
   <property>
       <name>hadoop.http.cross-origin.allowed-headers</name>
       <value>X-Requested-With,Content-Type,Accept,Origin</value>
     </property>
   ```
   
   it was not picked up for some reason.



-- 
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


Re: [PR] HDFS-17040. Namenode web UI should set content type to application/octet-stream when uploading a file. [hadoop]

Posted by "szetszwo (via GitHub)" <gi...@apache.org>.
szetszwo commented on PR #5721:
URL: https://github.com/apache/hadoop/pull/5721#issuecomment-2369168774

   Since this pull request already passed all the checks earlier, let's just merge it.


-- 
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


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

Posted by "hadoop-yetus (via GitHub)" <gi...@apache.org>.
hadoop-yetus commented on PR #5721:
URL: https://github.com/apache/hadoop/pull/5721#issuecomment-1578554079

   :confetti_ball: **+1 overall**
   
   
   
   
   
   
   | Vote | Subsystem | Runtime |  Logfile | Comment |
   |:----:|----------:|--------:|:--------:|:-------:|
   | +0 :ok: |  reexec  |   0m 48s |  |  Docker mode activated.  |
   |||| _ Prechecks _ |
   | +1 :green_heart: |  dupname  |   0m  0s |  |  No case conflicting files found.  |
   | +0 :ok: |  codespell  |   0m  0s |  |  codespell was not available.  |
   | +0 :ok: |  detsecrets  |   0m  0s |  |  detect-secrets was not available.  |
   | +0 :ok: |  jshint  |   0m  0s |  |  jshint was not available.  |
   | +1 :green_heart: |  @author  |   0m  0s |  |  The patch does not contain any @author tags.  |
   |||| _ trunk Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |  36m 14s |  |  trunk passed  |
   | +1 :green_heart: |  shadedclient  |  58m 54s |  |  branch has no errors when building and testing our client artifacts.  |
   |||| _ Patch Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |   1m  8s |  |  the patch passed  |
   | +1 :green_heart: |  blanks  |   0m  0s |  |  The patch has no blanks issues.  |
   | +1 :green_heart: |  shadedclient  |  22m 33s |  |  patch has no errors when building and testing our client artifacts.  |
   |||| _ Other Tests _ |
   | +1 :green_heart: |  asflicense  |   0m 35s |  |  The patch does not generate ASF License warnings.  |
   |  |   |  87m 19s |  |  |
   
   
   | Subsystem | Report/Notes |
   |----------:|:-------------|
   | Docker | ClientAPI=1.43 ServerAPI=1.43 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-5721/1/artifact/out/Dockerfile |
   | GITHUB PR | https://github.com/apache/hadoop/pull/5721 |
   | Optional Tests | dupname asflicense shadedclient codespell detsecrets jshint |
   | uname | Linux 73f0272140a2 4.15.0-206-generic #217-Ubuntu SMP Fri Feb 3 19:10:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux |
   | Build tool | maven |
   | Personality | dev-support/bin/hadoop.sh |
   | git revision | trunk / 395e833af9260432440092990df53be230771d86 |
   | Max. process+thread count | 530 (vs. ulimit of 5500) |
   | modules | C: hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project/hadoop-hdfs |
   | Console output | https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-5721/1/console |
   | versions | git=2.25.1 maven=3.6.3 |
   | Powered by | Apache Yetus 0.14.0 https://yetus.apache.org |
   
   
   This message was automatically generated.
   
   


-- 
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


Re: [PR] HDFS-17040. Namenode web UI should set content type to application/octet-stream when uploading a file. [hadoop]

Posted by "Galsza (via GitHub)" <gi...@apache.org>.
Galsza commented on code in PR #5721:
URL: https://github.com/apache/hadoop/pull/5721#discussion_r1771950619


##########
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 I'm not sure the CORS problem still exists. I've tested this using Chrome browser and with maximum security enabled the change was still working.



-- 
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


Re: [PR] HDFS-17040. Namenode web UI should set content type to application/octet-stream when uploading a file. [hadoop]

Posted by "EvanLiu2000 (via GitHub)" <gi...@apache.org>.
EvanLiu2000 commented on PR #5721:
URL: https://github.com/apache/hadoop/pull/5721#issuecomment-4275168486

    Core-sites.xml :
     <property>
       <name>hadoop.http.filter.initializers</name>
       <value>org.apache.hadoop.security.HttpCrossOriginFilterInitializer</value>
     </property>
   
     <property>
       <name>hadoop.http.cross-origin.enabled</name>
       <value>true</value>
     </property>
   
     <property>
       <name>hadoop.http.cross-origin.allowed-origins</name>
       <value>*</value>
     </property>
   
     <property>
       <name>hadoop.http.cross-origin.allowed-methods</name>
       <value>GET,POST,HEAD,PUT,OPTIONS,DELETE</value>
     </property>
   
   <property>
     <name>hadoop.http.cross-origin.allowed-headers</name>
     <value>Origin,Accept,Content-Type,content-type,X-Requested-With,Authorization</value>
   </property>
   
     <property>
       <name>hadoop.http.cross-origin.max-age</name>
       <value>1800</value>
     </property>
    
   My Folder Permissions:
   liuye@debian:~/hadoop/hadoop-3.5.0$ hadoop fs -ls -R /
   drwxr-xr-x   - dr.who supergroup          0 2026-04-19 12:21 /ad
   
   When I attempted to upload a file to the `/ad` directory via the NameNode WebUI, an issue occurred:
   
   Access to XMLHttpRequest at 'http://debian:9864/webhdfs/v1/ad/a.txt?op=CREATE&namenoderpcaddress=localhost:9000&createflag=&createparent=true&overwrite=false' from origin 'http://127.0.0.1:9870' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
   
   May I ask how I should resolve this issue?


-- 
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


Re: [PR] HDFS-17040. Namenode web UI should set content type to application/octet-stream when uploading a file. [hadoop]

Posted by "Galsza (via GitHub)" <gi...@apache.org>.
Galsza commented on PR #5721:
URL: https://github.com/apache/hadoop/pull/5721#issuecomment-2369155419

   @szetszwo could you please take another look at this PR?


-- 
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


Re: [PR] HDFS-17040. Namenode web UI should set content type to application/octet-stream when uploading a file. [hadoop]

Posted by "szetszwo (via GitHub)" <gi...@apache.org>.
szetszwo merged PR #5721:
URL: https://github.com/apache/hadoop/pull/5721


-- 
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


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

Posted by "szetszwo (via GitHub)" <gi...@apache.org>.
szetszwo commented on code in PR #5721:
URL: https://github.com/apache/hadoop/pull/5721#discussion_r1220851176


##########
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:
   Question: Is this a js running in client browsers?  The change here is to change the `contentType` when uploading a file from a client browser to HDFS.  Is it correct?



-- 
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


[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

Posted by "zeroflag (via GitHub)" <gi...@apache.org>.
zeroflag commented on code in PR #5721:
URL: https://github.com/apache/hadoop/pull/5721#discussion_r1221274841


##########
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:
   Yes I've seen that, but it wasn't overridden. Even if I explicitly added   
   
   ```xml
   <property>
       <name>hadoop.http.cross-origin.allowed-headers</name>
       <value>X-Requested-With,Content-Type,Accept,Origin</value>
     </property>
   ```
   
   to core-site.xml, it was not picked up for some reason.



-- 
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


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

Posted by "szetszwo (via GitHub)" <gi...@apache.org>.
szetszwo commented on code in PR #5721:
URL: https://github.com/apache/hadoop/pull/5721#discussion_r1221248416


##########
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:
   The list is the default values.  It can be overridden by init parameter; see
   https://github.com/apache/hadoop/blob/9de13f879af66a211b098166fd423b6900fc730d/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/http/CrossOriginFilter.java#L176-L185



-- 
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


Re: [PR] HDFS-17040. Namenode web UI should set content type to application/octet-stream when uploading a file. [hadoop]

Posted by "Galsza (via GitHub)" <gi...@apache.org>.
Galsza commented on PR #5721:
URL: https://github.com/apache/hadoop/pull/5721#issuecomment-2369152762

   Thanks for the patch, looking good to me +1
   
   I've tested this change in a cluster by trying to upload a file containing the text "hello %" via namenode ui. The change is indeed working. I haven't found a CORS related problem or at least Chrome browsers security levels don't seem to affect it.


-- 
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