[英]what's the wreq's way of creating custom cookies?
I want to make HTTP requests with some known cookie key-value pairs (eg k1=v1; k2=v2; ...
) using wreq , but can't find a convenient way of creating them. 我想使用wreq使用一些已知的cookie键值对(例如
k1=v1; k2=v2; ...
)发出HTTP请求,但找不到创建它们的便捷方法。
Because Cookie has many fields, I'd prefer a smart constructor than having to fill all fields on my own. 因为Cookie有很多字段,所以我更喜欢智能构造函数而不是自己填充所有字段。
By browsing documents, I find generateCookie to be the most promosing one (and that's also the only one I've found that returns a Cookie
): I can create SetCookie
and all I need are just key value pairs. 通过浏览文档,我发现generateCookie是最有发展的一个(这也是我发现的唯一一个返回
Cookie
):我可以创建SetCookie
,我只需要键值对。 But we don't have a Request to feed it as the second argument. 但我们没有请求将其作为第二个参数提供。 Using http-client alone, one can do parseUrl to create one.
单独使用http-client,可以使用parseUrl创建一个。 But in wreq I feel the author want to hide Request from user and I can't find a function that gives us direct access to it.
但是在wreq我觉得作者想要隐藏用户的请求,我找不到能让我们直接访问它的函数。
So my question is: are there better ways to create cookies in wreq than using Cookie
constructor? 所以我的问题是:有没有更好的方法在wreq中创建cookie而不是使用
Cookie
构造函数?
I'd probably fork the generateCookie
implementation, as it looks like the Request
argument is used only to validate the fields. 我可能会分叉
generateCookie
实现,因为看起来Request
参数仅用于验证字段。
http://hackage.haskell.org/package/http-client-0.4.26.2/docs/src/Network-HTTP-Client-Cookies.html#generateCookie , except for default cookie path, as SetCookie
has Maybe
path. http://hackage.haskell.org/package/http-client-0.4.26.2/docs/src/Network-HTTP-Client-Cookies.html#generateCookie ,默认cookie路径除外,因为
SetCookie
具有Maybe
路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.