Comments (12)
后面有代码:req.Header.Set("Content-Type", w.FormDataContentType()) 会设置。
from requests.
后面有代码:req.Header.Set("Content-Type", w.FormDataContentType()) 会设置。
你检查下吧。我抓包分析的,并没有带有。
刚才特意看了下代码。应该是有问题的。会被这个文件检查条件,干掉。
from requests.
Content-Type", "application/x-www-form-urlencoded。顺便说下,是这个头
from requests.
你把你的测试代码发一下,我看看。
from requests.
func GetKillInitInfo(skuId string, num string) (initData InitData, err error) {
url := "https://marathon.jd.com/seckillnew/orderService/pc/init.action"
header := requests.Header{
"Host": "marathon.jd.com",
}
data := requests.Datas{
"sku": skuId,
"num": num,
"isModifyAddress": "false",
}
// 两个图的差异,就是因为我在外面特殊的处理了一下。默认是没有这个头的,所以认为有问题!!!
header["Content-Type"] = "application/x-www-form-urlencoded"
resp, err := sessionReq.Post(url, header, data)
if err != nil {
fmt.Println("fuck initinfo 获取失败了。好好思考一下")
return InitData{}, errors.New("请求错误")
}
var initdata InitData
resp.Json(&initdata)
if len(initData.AddressList) == 0 {
return InitData{}, errors.New("响应错误,估计被频率限制了")
}
return initdata, nil
}
from requests.
好的,我测试出来了,我试着改改
from requests.
好的,我测试出来了,我试着改改
哈哈。
from requests.
我把if 判断去掉了。不过这样多次调用,他会不会重复加。你试试吧。
from requests.
419行,有一个问题,强制设置的话,别人就不能自己改了。这不好。
from requests.
419行,有一个问题,强制设置的话,别人就不能自己改了。这不好。
你看后面,在解析外部传来的header的时候,会重新设置header。用户的传参如果设置了会直接覆盖这个默认逻辑。也就是说。用户的设置相当于优先级最高。
from requests.
我把if 判断去掉了。不过这样多次调用,他会不会重复加。你试试吧。
单纯去掉if。应该是不行的。
因为我看到。header的数据结构为:type Header map[string][]string
再看下,add,set,get,的逻辑。
set会去覆盖,添加新值
add。是去给一个key追加一个新的元素。
而get是获取这个key的元素列表的第一个。
所以,set是合适的。add不合适。因为一直add不是我们的想法。也会造成内存问题。
from requests.
我现在的做法是 强制设置了 content-type,如果你想改变每次都加在header里设置。
如果有问题欢迎再次沟通。谢谢你的宝贵意见。
from requests.
Related Issues (20)
- post方法为什么不支持实时插入cookies呢? HOT 2
- 请问后期会支持digestauth?
- [Error]connectex: An attempt was made to access a socket in a way forbidden by its access permissions HOT 1
- 目前body中支持数组吗 HOT 1
- 你好 请问有人在生产上使用过这个吗 HOT 1
- New fetures HOT 1
- 代理 HOT 1
- 头信息首字母小写如何设置? HOT 1
- 怎么使用代理服务器? HOT 1
- resp.Json()默认不传参,用法更符合requests HOT 3
- 是否是并发不安全的 HOT 1
- How can I disable Cert Verification? HOT 1
- can we get history of request
- Can someone post an example of using session, for making multiple requests, persisting cookies for each request.
- download large text response text is incomplete
- what timeout
- who is this?
- 能否增加session支持
- How to set DNS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from requests.