403 when downloading from cloudfront with wget (after 302)

3

1

I'm trying to download file from cloudfront. It is a file archive from scala-sbt website. When using browser (Chrome) everything is ok. Basically the flow looks like:

https://dl.bintray.com/sbt/native-packages/sbt/0.13.8/sbt-0.13.8.zip -> HTTP 302
https://d29vzk4ow07wi7.cloudfront.net/155d6ff3bc178745ad4f951b7..... -> HTTP 200

Cloudfront url looks like this

https://d29vzk4ow07wi7.cloudfront.net/5ed3d97f83782ac965c5eb7256fc52df41dfa317

and contains parameters

response-content-disposition:attachment;filename="sbt-0.13.8.zip"
Policy:eyJTdGF0ZW1lbnQiOiBbeyJSZXNvdXJjZSI6Imh0dHAqOi8vZDI5dnprNG93MDd3aTcuY2xvdWRmcm9udC5uZXQvNWVkM2Q5N2Y4Mzc4MmFjOTY1YzVlYjcyNTZmYzUyZGY0MWRmYTMxNz9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPWF0dGFjaG1lbnQlM0JmaWxlbmFtZSUzRCUyMnNidC0wLjEzLjguemlwJTIyIiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNDM3NzI5Nzc3fSwiSXBBZGRyZXNzIjp7IkFXUzpTb3VyY2VJcCI6IjAuMC4wLjAvMCJ9fX1dfQ__
Signature:peffptUvUMLisjf3AH~QsRv~BOG3I6UMlU-MMfQRZ62D7StDWZ8cwDyraR54iq6t1avVxR3hR~p~8dDKb~bF1oSI6BlcRP0fXQZYz5DIECZ5rELA2W8XX6EIlPUmB6XHFZFlifYIalu8HG7N5WbS6Vrm87-O809GQni~AxuHw92kXrpZy~QmAShlldFNaikNtXqytA1a2ayX-yotY4tafGTvq7zhXgs2zqj4Qw0zp8Lt7rpam3DASgeBXge8mrb118qfoXMd431iMxi-4AjxncLiaDbYXbaCs7j~7SzlNd0jCyLbHbekp58nqjP9hEGdv2KixSwPw4M7D7DwlVc8pA__
Key-Pair-Id:APKAIFKFWOMXM2UMTSFA

When I use wget:

wget https://dl.bintray.com/sbt/native-packages/sbt/0.13.8/sbt-0.13.8.zip

I get 302 and then 403 on this cloudfront URL

--2015-07-17 11:03:45--  https://dl.bintray.com/sbt/native-packages/sbt/0.13.8/sbt-0.13.8.zip                                                                                                                            
...........................................                                                                                                                                        
HTTP request sent, awaiting response... 302                                                                                                                                                                              
Location: https://d29vzk4ow07wi7.cloudfront.net/155d6ff3bc178....[following]                                                                                                                                       
..........................
--2015-07-17 11:03:46-  https://d29vzk4ow07wi7.cloudfront.net/155d6ff3bc178...                                                                                                                                      
....................................................                                                                                                            
HTTP request sent, awaiting response... 403 Forbidden                                                                                                                                                                    
2015-07-17 11:03:46 ERROR 403: Forbidden.   

When I use direct cloudfront URL like this:

wget  "https://d29vzk4ow07wi7.cloudfront.net/5ed3d97f8378...."                                                                                                                                 

I get 403 and then 200 OK (there is loop in which wget probably shortens this name). I also used -O and then I also got 403 and then 200 OK in second try.

The name is too long, 886 chars total.                                                                                                                                                                                   
.....................................                                                                                                                                                                                                
New name is 5ed3d97f8378....                                                                                                                                                                                         
--2015-07-24 09:19:30--      https://d29vzk4ow07wi7.cloudfront.net/5ed3d97f83782....                                                                                                                                 
.....................................................                                                                                                           
HTTP request sent, awaiting response... 403 Forbidden                                                                                                                                                                    
.....................................................                                                                                                                                                                               
Trying to shorten...                                                                                                                                                                                                     
New name is 5ed3d97f8378....                                                                                                                                                                                         
--2015-07-24 09:19:30--  https://d29vzk4ow07wi7.cloudfront.net/5ed3d97f8378....                                                                                                                                    
.........................................                                                                                                                                                       
HTTP request sent, awaiting response... 200 OK                                                                                                                                                                           
..............................................  

2015-07-24 09:19:31 (1.18 MB/s) - '5ed3d97f8378....' saved [1060604/1060604]                                                                                                                                          

Is there something that I am missing? I didn't mention anything about cookies or headers because in second case I did it without it. Maybe that connection reuse in second example is the key?

Linux version:

Linux version 3.10.0-229.7.2.el7.x86_64 (builder@kbuilder.dev.centos.org)
(gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) 
#1 SMP Tue Jun 23 22:06:11 UTC 2015     

wget version:

GNU Wget 1.16 built on linux-gnu.  

Jacek

Posted 2015-07-24T09:49:34.037

Reputation: 31

"The name is too long, 886 chars total." wget and some file systems seem to be having problems with long URLs. Try to use curl instead. – Abdull – 2015-09-11T14:18:55.787

No answers