Details
-
Task
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
Description
I have a habit of setting "Content-Type: text/xml" for curl commands. Today, I had a bad time debugging the 400 error for below command. Finally, this discussion(https://issues.apache.org/jira/browse/HBASE-14147?focusedCommentId=15205420&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15205420) helped me in resolving the problem.
As pointed out by mwarhaftig and misty in their discussion in HBASE-14147, a curl request of the following form will throw a 400 BAD REQUEST
curl -vi -X POST -H "Accept: text/xml" -H "Content-Type: text/xml" "http://my_server:20550/namespaces/new_ns2/"
I think we should document this in the description for "Create a new namespace" explicitly mentioning that users should take care "Content-Type" is not set for this particular command. Similarly for "Alter an existing namespace" command.
- With "Content-Type: text/xml": INCORRECT
- Command:
curl -vi --negotiate -u:test -X POST -H "Accept: text/xml" -H "Content-Type: text/xml" http://host-xx-xx-xx-xx:xxxx/namespaces/testspace123
- Output:
* Hostname was NOT found in DNS cache * Trying xx.xx.xx.xx... * Connected to host-xx-xx-xx-xx (xx.xx.xx.xx) port xxxx (#0) > POST /namespaces/testspace123 HTTP/1.1 > User-Agent: curl/xx.xx.xx > Host: host-xx-xx-xx-xx:xxxx > Accept: text/xml > Content-Type: text/xml > < HTTP/1.1 401 Authentication required HTTP/1.1 401 Authentication required < WWW-Authenticate: Negotiate WWW-Authenticate: Negotiate < Set-Cookie: hadoop.auth=; Path=/; Expires=Thu, 01-Jan-1970 00:00:00 GMT; HttpOnly Set-Cookie: hadoop.auth=; Path=/; Expires=Thu, 01-Jan-1970 00:00:00 GMT; HttpOnly < Content-Type: text/html; charset=iso-8859-1 Content-Type: text/html; charset=iso-8859-1 < Cache-Control: must-revalidate,no-cache,no-store Cache-Control: must-revalidate,no-cache,no-store < Content-Length: 1416 Content-Length: 1416 < * Ignoring the response-body * Connection #0 to host host-xx-xx-xx-xx left intact * Issue another request to this URL: 'http://host-xx-xx-xx-xx:xxxx/namespaces/testspace123' * Found bundle for host host-xx-xx-xx-xx: 0x24b51a0 * Re-using existing connection! (#0) with host host-xx-xx-xx-xx * Connected to host-xx-xx-xx-xx (xx.xx.xx.xx) port xxxx (#0) * Server auth using GSS-Negotiate with user '' > POST /namespaces/testspace123 HTTP/1.1 > Authorization: Negotiate xxxxxxxxxxxxxxxxxxxxxx > User-Agent: curl/7.37.0 > Host: host-xx-xx-xx-xx:xxxx > Accept: text/xml > Content-Type: text/xml > < HTTP/1.1 400 Bad Request HTTP/1.1 400 Bad Request < WWW-Authenticate: Negotiate xxxxxxxxxxxxxxxxxxxxxx WWW-Authenticate: Negotiate xxxxxxxxxxxxxxxxxxxxxx < Set-Cookie: hadoop.auth="u=xxxx&p=xxx/xxxx@xxxx.COM&t=kerberos&e=1528817880151&s=xxxxxxxxxxxxxxx="; Path=/; Expires=Tue, 12-Jun-2018 15:38:00 GMT; HttpOnly Set-Cookie: hadoop.auth="u=xxxx&p=xxx/xxxx@xxxx.COM&t=kerberos&e=1528817880151&s=xxxxxxxxxxxxxxx="; Path=/; Expires=Tue, 12-Jun-2018 15:38:00 GMT; HttpOnly < Content-Type: text/html; charset=iso-8859-1 Content-Type: text/html; charset=iso-8859-1 < Cache-Control: must-revalidate,no-cache,no-store Cache-Control: must-revalidate,no-cache,no-store < Content-Length: 1392 Content-Length: 1392 < <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> <title>Error 400 Bad Request</title> </head> <body><h2>HTTP ERROR 400</h2> <p>Problem accessing /namespaces/testspace123. Reason: <pre> Bad Request</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> </body> </html> * Closing connection 0
- Command:
- Without "Content-Type: text/xml": CORRECT
- Command:
curl -vi --negotiate -u:test -X POST -H "Accept: text/xml" http://host-xx-xx-xx-xx:xxxx/namespaces/testspace123
- Output:
* Hostname was NOT found in DNS cache * Trying xx.xx.xx.xx... * Connected to host-xx-xx-xx-xx- (xx.xx.xx.xx) port xxxx (#0) > POST /namespaces/testspace123 HTTP/1.1 > User-Agent: curl/xx.xx.xx > Host: host-xx-xx-xx-xx:xxxx > Accept: text/xml > < HTTP/1.1 401 Authentication required HTTP/1.1 401 Authentication required < WWW-Authenticate: Negotiate WWW-Authenticate: Negotiate < Set-Cookie: hadoop.auth=; Path=/; Expires=Thu, 01-Jan-1970 00:00:00 GMT; HttpOnly Set-Cookie: hadoop.auth=; Path=/; Expires=Thu, 01-Jan-1970 00:00:00 GMT; HttpOnly < Content-Type: text/html; charset=iso-8859-1 Content-Type: text/html; charset=iso-8859-1 < Cache-Control: must-revalidate,no-cache,no-store Cache-Control: must-revalidate,no-cache,no-store < Content-Length: 1416 Content-Length: 1416 < * Ignoring the response-body * Connection #0 to host host-xx-xx-xx-xx left intact * Issue another request to this URL: 'http://host-xx-xx-xx-xx:xxxx/namespaces/testspace123' * Found bundle for host host-xx-xx-xx-xx: 0x1768160 * Re-using existing connection! (#0) with host host-xx-xx-xx-xx * Connected to host-xx-xx-xx-xx (xx.xx.xx.xx) port xxxx (#0) * Server auth using GSS-Negotiate with user '' > POST /namespaces/testspace123 HTTP/1.1 > Authorization: Negotiate xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx > User-Agent: curl/xx.xx.0 > Host: host-xx-xx-xx-xxx:xxxx > Accept: text/xml > < HTTP/1.1 201 Created HTTP/1.1 201 Created < WWW-Authenticate: Negotiate xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx WWW-Authenticate: Negotiate xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx < Set-Cookie: hadoop.auth="u=xxxx&p=xxx/xxxx@xxxx.COM&t=kerberos&e=1528817880151&s=xxxxxxxxxxxxxxx="; Path=/; Expires=Tue, 12-Jun-2018 15:38:00 GMT; HttpOnly Set-Cookie: hadoop.auth="u=xxxx&p=xxx/xxxx@xxxx.COM&t=kerberos&e=1528817880151&s=xxxxxxxxxxxxxxx="; Path=/; Expires=Tue, 12-Jun-2018 15:38:00 GMT; HttpOnly < Location: http://host-xx-xx-xx-xx:xxxx/namespaces/testspace123 Location: http://host-xx-xx-xx-xx:xxxx/namespaces/testspace123 < Content-Length: 0 Content-Length: 0 < * Closing connection 0
- Command: