简体   繁体   中英

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.

Because Cookie has many fields, I'd prefer a smart constructor than having to fill all fields on my own.

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. 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. 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.

So my question is: are there better ways to create cookies in wreq than using Cookie constructor?

I'd probably fork the generateCookie implementation, as it looks like the Request argument is used only to validate the fields.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM