[ 
https://issues.apache.org/jira/browse/HBASE-20715?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16509232#comment-16509232
 ] 

Nihal Jain edited comment on HBASE-20715 at 6/12/18 6:17 AM:
-------------------------------------------------------------

{quote} what the default Content-Type is assumed to be when you don't supply it?
{quote}
I am not sure about this. Have added the logs.
{quote}Is there specific documentation somewhere that you think should be 
updated?
{quote}
As this problem will occur in case we have a POST/PUT without data, we have 
only two such commands:
 * Alter an existing namespace
{code:java}
curl -vi -X POST   -H "Accept: text/xml"  
"example.com:8000/namespaces/special_ns"
{code}

 * Alter an existing namespace
{code:java}
curl -vi -X PUT  -H "Accept: text/xml"  
"http://example.com:8000/namespaces/special_ns";
{code}

I think it would be enough to mention this in the description of these commands.

 


was (Author: nihaljain.cs):
{quote} what the default Content-Type is assumed to be when you don't supply it?
{quote}
I am not sure about this. Have added the logs.

bq. Is there specific documentation somewhere that you think should be updated?
As this problem will occur in case we have a POST/PUT without data, we have 
only two such commands:
* Alter an existing namespace
{code:java}
curl -vi -X POST   -H "Accept: text/xml"  
"example.com:8000/namespaces/special_ns"
{code}

* Alter an existing namespace
{code:java}
curl -vi -X PUT  -H "Accept: text/xml"  
"http://example.com:8000/namespaces/special_ns
{code}

I think it would be enough to mention this in the description of these commands.

 


> REST curl command for create namespace with "Content-Type: text/xml" 
> specified (mistakenly) results in a 400 Bad Request
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-20715
>                 URL: https://issues.apache.org/jira/browse/HBASE-20715
>             Project: HBase
>          Issue Type: Task
>          Components: documentation, REST
>            Reporter: Nihal Jain
>            Priority: Minor
>
> 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}}
> {code:java}
> curl -vi -X POST -H "Accept: text/xml" -H "Content-Type: text/xml"  
> "http://my_server:20550/namespaces/new_ns2/";
> {code}
> 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:
> {code:java}
> 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
> {code}
> ** Output:
> {noformat}
> * 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/[email protected]&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/[email protected]&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
> {noformat}
>  * *Without {{"Content-Type: text/xml":}}* CORRECT
> ** Command:
> {code:java}
> curl -vi --negotiate -u:test -X POST -H "Accept: text/xml" 
> http://host-xx-xx-xx-xx:xxxx/namespaces/testspace123
> {code}
> ** Output:
> {noformat}
> * 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/[email protected]&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/[email protected]&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
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to