You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-user@hadoop.apache.org by Jingfei Hu <ji...@hotmail.com> on 2015/10/13 03:53:59 UTC

Http request uri query parameters of the redirected location

Hi team,

I am using WebHDFS rest api to read from and write to HDFS cluster files.
I've got a minor question when using curl command line to practice some
apis.  It's

 

Would the query parameters be appended to the redirected location when
creating files or any other apis which needs a redirect?

 

Of course, I tried out. And it seems work in that way. 

 

curl -i -X PUT "http://xxx:50070/webhdfs/v1/hellowworld?op=CREATE

 

If I put it a &user.name=hadoop, then the redirected location would also
contain such a query parameter. 

 

My further question is it's by design or not. Can I make this assumption
when writing codes?

 

Thanks,

Jingfei


Re: Http request uri query parameters of the redirected location

Posted by Chris Nauroth <cn...@hortonworks.com>.
Hello Jingfei,

Yes, the relevant query parameters are included in the redirect location of the HTTP 302 response, and this is by design.

Many of the curl examples in the WebHDFS documentation use the curl -L option.

http://hadoop.apache.org/docs/r2.7.1/hadoop-project-dist/hadoop-hdfs/WebHDFS.html

Passing the -L option to the curl command will cause it to follow redirects automatically.  We expect this would work correctly, because the redirect location in the HTTP 302 response has the complete query parameter information, and curl -L would use this in its subsequent HTTP request.

--Chris Nauroth

From: Jingfei Hu <ji...@hotmail.com>>
Reply-To: "user@hadoop.apache.org<ma...@hadoop.apache.org>" <us...@hadoop.apache.org>>
Date: Monday, October 12, 2015 at 6:53 PM
To: "user@hadoop.apache.org<ma...@hadoop.apache.org>" <us...@hadoop.apache.org>>
Cc: Jingfei Hu <ji...@hotmail.com>>
Subject: Http request uri query parameters of the redirected location

Hi team,
I am using WebHDFS rest api to read from and write to HDFS cluster files. I've got a minor question when using curl command line to practice some apis.  It's

Would the query parameters be appended to the redirected location when creating files or any other apis which needs a redirect?

Of course, I tried out. And it seems work in that way.

curl -i -X PUT "http://xxx:50070/webhdfs/v1/hellowworld?op=CREATE

If I put it a &user.name=hadoop, then the redirected location would also contain such a query parameter.

My further question is it's by design or not. Can I make this assumption when writing codes?

Thanks,
Jingfei

Re: Http request uri query parameters of the redirected location

Posted by Chris Nauroth <cn...@hortonworks.com>.
Hello Jingfei,

Yes, the relevant query parameters are included in the redirect location of the HTTP 302 response, and this is by design.

Many of the curl examples in the WebHDFS documentation use the curl -L option.

http://hadoop.apache.org/docs/r2.7.1/hadoop-project-dist/hadoop-hdfs/WebHDFS.html

Passing the -L option to the curl command will cause it to follow redirects automatically.  We expect this would work correctly, because the redirect location in the HTTP 302 response has the complete query parameter information, and curl -L would use this in its subsequent HTTP request.

--Chris Nauroth

From: Jingfei Hu <ji...@hotmail.com>>
Reply-To: "user@hadoop.apache.org<ma...@hadoop.apache.org>" <us...@hadoop.apache.org>>
Date: Monday, October 12, 2015 at 6:53 PM
To: "user@hadoop.apache.org<ma...@hadoop.apache.org>" <us...@hadoop.apache.org>>
Cc: Jingfei Hu <ji...@hotmail.com>>
Subject: Http request uri query parameters of the redirected location

Hi team,
I am using WebHDFS rest api to read from and write to HDFS cluster files. I've got a minor question when using curl command line to practice some apis.  It's

Would the query parameters be appended to the redirected location when creating files or any other apis which needs a redirect?

Of course, I tried out. And it seems work in that way.

curl -i -X PUT "http://xxx:50070/webhdfs/v1/hellowworld?op=CREATE

If I put it a &user.name=hadoop, then the redirected location would also contain such a query parameter.

My further question is it's by design or not. Can I make this assumption when writing codes?

Thanks,
Jingfei

Re: Http request uri query parameters of the redirected location

Posted by Chris Nauroth <cn...@hortonworks.com>.
Hello Jingfei,

Yes, the relevant query parameters are included in the redirect location of the HTTP 302 response, and this is by design.

Many of the curl examples in the WebHDFS documentation use the curl -L option.

http://hadoop.apache.org/docs/r2.7.1/hadoop-project-dist/hadoop-hdfs/WebHDFS.html

Passing the -L option to the curl command will cause it to follow redirects automatically.  We expect this would work correctly, because the redirect location in the HTTP 302 response has the complete query parameter information, and curl -L would use this in its subsequent HTTP request.

--Chris Nauroth

From: Jingfei Hu <ji...@hotmail.com>>
Reply-To: "user@hadoop.apache.org<ma...@hadoop.apache.org>" <us...@hadoop.apache.org>>
Date: Monday, October 12, 2015 at 6:53 PM
To: "user@hadoop.apache.org<ma...@hadoop.apache.org>" <us...@hadoop.apache.org>>
Cc: Jingfei Hu <ji...@hotmail.com>>
Subject: Http request uri query parameters of the redirected location

Hi team,
I am using WebHDFS rest api to read from and write to HDFS cluster files. I've got a minor question when using curl command line to practice some apis.  It's

Would the query parameters be appended to the redirected location when creating files or any other apis which needs a redirect?

Of course, I tried out. And it seems work in that way.

curl -i -X PUT "http://xxx:50070/webhdfs/v1/hellowworld?op=CREATE

If I put it a &user.name=hadoop, then the redirected location would also contain such a query parameter.

My further question is it's by design or not. Can I make this assumption when writing codes?

Thanks,
Jingfei

Re: Http request uri query parameters of the redirected location

Posted by Chris Nauroth <cn...@hortonworks.com>.
Hello Jingfei,

Yes, the relevant query parameters are included in the redirect location of the HTTP 302 response, and this is by design.

Many of the curl examples in the WebHDFS documentation use the curl -L option.

http://hadoop.apache.org/docs/r2.7.1/hadoop-project-dist/hadoop-hdfs/WebHDFS.html

Passing the -L option to the curl command will cause it to follow redirects automatically.  We expect this would work correctly, because the redirect location in the HTTP 302 response has the complete query parameter information, and curl -L would use this in its subsequent HTTP request.

--Chris Nauroth

From: Jingfei Hu <ji...@hotmail.com>>
Reply-To: "user@hadoop.apache.org<ma...@hadoop.apache.org>" <us...@hadoop.apache.org>>
Date: Monday, October 12, 2015 at 6:53 PM
To: "user@hadoop.apache.org<ma...@hadoop.apache.org>" <us...@hadoop.apache.org>>
Cc: Jingfei Hu <ji...@hotmail.com>>
Subject: Http request uri query parameters of the redirected location

Hi team,
I am using WebHDFS rest api to read from and write to HDFS cluster files. I've got a minor question when using curl command line to practice some apis.  It's

Would the query parameters be appended to the redirected location when creating files or any other apis which needs a redirect?

Of course, I tried out. And it seems work in that way.

curl -i -X PUT "http://xxx:50070/webhdfs/v1/hellowworld?op=CREATE

If I put it a &user.name=hadoop, then the redirected location would also contain such a query parameter.

My further question is it's by design or not. Can I make this assumption when writing codes?

Thanks,
Jingfei