Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you give an example how to use cookie in http request? #360

Closed
kopes18 opened this issue Dec 6, 2018 · 2 comments
Closed

Can you give an example how to use cookie in http request? #360

kopes18 opened this issue Dec 6, 2018 · 2 comments

Comments

@kopes18
Copy link

kopes18 commented Dec 6, 2018

I want to use custom cookies when http request, cant find any doc demonstrate this.

Julia 1
HTTP.jl 0.6.15

@kvantitative
Copy link

kvantitative commented Dec 17, 2018

I have the same request. I have been using the Julia package Requests.jl but need to convert to HTTP.jl. This involve translating legacy client code that uses using Requests.jl.

using Request
response=get(url; cookies = Dict("NAME" => "value"))

Where 'response' is the response from the server, url is the URL to the server, "NAME" is the name of a cookie stored locally and "value" is the value of that cookie.

I figured that HTTP.jl uses HTTP.CookieRequest.default_cookiejar, that seems to be a Dict. I did some experiments, and it seems like the key in this Dict is the server address (=url?) and the values is a list of cookies defined as HTTP.Cookies.Cookie("NAME", "value"). However, it is impossible for me to get this working, so an example the mimic the Request.jl code listed above would be highly appreciated.

Julia 0.7 and 1.0
HTTP.jl 0.6.15

@quinnj
Copy link
Member

quinnj commented Jan 23, 2019

Hi @kopes18 and @kvantitative, I've added the ability, like Requests.jl, to pass cookies=Dict(name=>value) with HTTP.jl requests. Let me know if you have any issues. Previously, you could pass in your own cookiejar, but that can be tricky to manage because the host of the Cookie has to match the request you're making.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants