正向代理訪問騰訊雲cos時http405的問題

當使用正向代理請求cos資源的時候,cos對http協議的支持會比較嚴謹,「寬容性」不夠。可能對http協議更加謹慎一點反而更好吧curl

響應405的請求細節ui

GET http://nfs-test.cosgz.myqcloud.com/user_logo/1000293461_50x50.jpg?sign=testsign HTTP/1.1
Host: nfs-test.cosgz.myqcloud.com
User-Agent: curl
Accept: */*

HTTP/1.1 405 Error
Server: TencentCOS
Content-Type: text/octet
ServerIP: 127.1.1.1
Content-Length: 78

{"errorcode":-46152,"errormsg":"bucket name has illegal char, retcode:-46152"}

正常的請求應該是url

GET /user_logo/1000293461_50x50.jpg?sign=testsign HTTP/1.1
User-Agent: curl/7.29.0
Host: nfs-test.cosgz.myqcloud.com
Accept: */*

當使用有的正向代理的時候,頭部GET部分會跟正常的請求不同,而cos的服務只認第二種寫法(標準的http協議),固然有一些站點就兼容第一種的寫法:look代理

* Rebuilt URL to: www.baidu.com/
*   Trying proxy-ip...
* Connected to  proxy-ip ( proxy-ip) port 8090 (#0)
* Proxy auth using Basic with user 'mom'
> GET http://www.baidu.com/ HTTP/1.1
> Host: www.baidu.com
> Proxy-Authorization: Basic uuuuuuuuuuuuu
> User-Agent: curl
> Accept: */*
> 
< HTTP/1.1 200 OK
< Accept-Ranges: bytes

若是仍是用http,1.1的協議,正向代理必須開啓通道模式,這樣正向代理的get頭部拼裝就會中止,訪問cos就正常了,好比這樣code

curl -v --proxy "proxy-ip:8090"   --proxytunnel "http://nfs-test.cosgz.myqcloud.com/user_logo/1000293461_50x50.jpg?sign=your-sign"

或者直接使用Https協議orm

相關文章
相關標籤/搜索