Requests.jl icon indicating copy to clipboard operation
Requests.jl copied to clipboard

HTTP/2 Support

Open sorpaas opened this issue 9 years ago • 11 comments

This pull request adds HTTP/2 support for Requests.jl. Help on testing and code review are highly appreciated!

To use it, you need to checkout master of HPack.jl (header compression implementation), HTTP2.jl (HTTP/2 protocol implementation) and MbedTLS.jl.

For a simple test, install nghttp. Run in shell nghttpd --verbose --no-tls --hexdump 9000 to start a server and then in Julia:

using Requests
res = get("http://127.0.0.1:9000", http2=true)

@show res.headers

To test HTTPS, create a test certificate and key. Start the server by nghttpd --verbose --hexdump 9000 test.key test.crt and then in Julia:

using Requests
res = get("https://127.0.0.1:9000", tls_conf=Requests.TLS_NOVERIFY, http2=true)

@show res.headers

You can also test it against a server in the real world. Usually, wild HTTP/2 servers require HTTPS support.

using Requests
res = get("https://www.google.com", http2=true)

sorpaas avatar Aug 04 '16 17:08 sorpaas

Updated MbedTLS and HTTP2's version and tests should pass now.

sorpaas avatar Aug 08 '16 16:08 sorpaas

Hey @sorpaas, hoping to merge this soon. I tried rerunning the Travis tests and there seems to be a sporadic failure. Any idea what's going on?

malmaud avatar Oct 04 '16 14:10 malmaud

I still cannot reproduce that locally even now I got a MacBook. On Travis it is still a segmentation fault only on nightly:

signal (11): Segmentation fault: 11
while loading /Users/travis/.julia/v0.6/Requests/test/runtests.jl, in expression starting on line 189
strlen at /usr/lib/system/libsystem_c.dylib (unknown line)

Also, any ways to run the Travis build locally on OS X? I thought of Docker but it uses a VM so it's still Linux.

sorpaas avatar Oct 05 '16 06:10 sorpaas

Also, the line 189 (where it fails) actually doesn't relate to HTTP2:

@test statuscode(get("https://httpbin.org")) == 200

sorpaas avatar Oct 05 '16 06:10 sorpaas

@malmaud Tests now passed on nightly! :)

It turns out to be a problem with MbedTLS. Failing back to version 0.2.1 now works.

sorpaas avatar Oct 05 '16 06:10 sorpaas

It fails again.... :(

I guess the segmentation fault is somehow related to MbedTLS.

sorpaas avatar Oct 05 '16 06:10 sorpaas

Codecov Report

Merging #133 into master will increase coverage by 2.23%. The diff coverage is 60%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #133      +/-   ##
==========================================
+ Coverage   68.68%   70.92%   +2.23%     
==========================================
  Files           4        4              
  Lines         511      626     +115     
==========================================
+ Hits          351      444      +93     
- Misses        160      182      +22
Impacted Files Coverage Δ
src/Requests.jl 65.03% <56.41%> (+6.65%) :arrow_up:
src/streaming.jl 78.35% <76.47%> (+4.19%) :arrow_up:
src/parsing.jl 90.32% <0%> (-1.08%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2ea3eca...56d5097. Read the comment docs.

codecov-io avatar Nov 19 '16 15:11 codecov-io

try again ci?

musm avatar Mar 20 '17 15:03 musm

Ah, I'm really sorry that I haven't got this merged. I'll try to re-base the code and do code improvements. (Might take a few days due to my workload recently ...)

sorpaas avatar Mar 20 '17 18:03 sorpaas

I think HTTP.jl is probably the future of the Julia we stack. Would be awesome to get it merged there. On Mon, Mar 20, 2017 at 2:14 PM Wei Tang [email protected] wrote:

Ah, I'm really sorry that I haven't got this merged. I'll try to re-base the code and do code improvements. (Might take a few days due to my workload https://that.world/%7Ewei/busy/ recently ...)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/JuliaWeb/Requests.jl/pull/133#issuecomment-287849833, or mute the thread https://github.com/notifications/unsubscribe-auth/AA8SvQ-wTLC-bPAQX6NeYo-xt1gmIlPFks5rnsHogaJpZM4Jc8qw .

malmaud avatar Mar 20 '17 18:03 malmaud

Note I am having the same failure on the http post test at https://github.com/JuliaWeb/Requests.jl/pull/151 it only recently started failing and I believe it's unrelated

musm avatar Apr 03 '17 13:04 musm