-
Notifications
You must be signed in to change notification settings - Fork 181
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
clarification on cookie types and behavior #690
Comments
Thanks for opening an issue; it's certainly something we should improve on in the docs (thanks for the example PR that already helps a little at least!). My thoughts:
|
Trying again this morning after a cup of coffee (rather than 4:30 on a Friday), I was wrong and can confirm that the cookie behavior works as you describe. Where I think I was going wrong previously was I was also moving around how I was passing in credentials as a
To your bullet points, I do think some kind of convenience function/struct field to be able to view cookies would be nice. I was running sanity checks in python on the side and could view cookies with a simple I think the better title for this issue is probably more about previously I was creating a dictionary and wrapping it like payload = Dict("username" => "username",
"pass" => "password")
#does not work
HTTP.post(someurl.com, headers = ["somekey" => "somevalue"], HTTP.Form(payload); cookies = true)
#returns ERROR: IOError(EOFError() during request(someurl.com))
#getting rid of the HTTP.Form and moving form payload key/values to header array worked for me, same call as above
HTTP.post(someurl.com, headers = ["somekey" => "somevalue", "username" => "username",
"pass" => "password" ]; cookies = true)
probably a better question is how should `HTTP.Form` be used in requests? |
Going to close this for now as a more broad documentation update is planned and coming soon. Also as a quick follow up, in #836, there are some cookie improvements, in particular, we'll be able to call |
Julia 1.5.3
HTTP.jl 0.9.5
MbedTLS.jl 1.0.3
I am working on a script that submits gets some credentials and submits a webform in a persistent session. I'm writing this away from the computer where it happened so actual error and version details are a little fuzzy. I think this is an "understanding the docs" rather than technical.
I am able to successfully pass the first part and generate the session tokens using the
cookies
flag like:HTTP.get(someurl.com, headers = ["somekey" => "somevalue"]; cookies = true)
I can also view the returned cookies using
HTTP.CookiesRequest.default_cookiejar
and now need to be able to pass them back in my request. I thought from reading the docstrings I could use either thecookies
orcookiejar
flag to pass them back in directly such as:HTTP.post(someurl.com, headers = ["somekey" => "somevalue"]; cookiejar = default_cookiejar)
but that errors with
default_cookiejar not found
.My second attempt with copy pasting the tokens into a
Dict
fails to return200
(usually with some kind of EOF error?).HTTP.post(someurl.com, headers = ["somekey" => "somevalue"]; cookies = Dict("cookie1" => "cookie2","somekey" => "somevalue","cookie3" => "somevalue"))
Long story short, I was able to get a successful return after reading this discourse post and modifying my script to pass the hardcoded cookie strings in the
header
array like:HTTP.post(someurl.com, headers = ["somekey" => "somevalue","cookie1" => "cookie2","somekey" => "somevalue","cookie3" => "somevalue"])
Happy to take a stab at a PR with some guidance. I guess my questions so far include:
; cookies = Dict(...)
syntax still valid or should everything just go straight into headers?CookiesRequest.default_cookiejar
syntax is mentioned anywhere in docstrings, where is a good place for that be added/clarified?The text was updated successfully, but these errors were encountered: