You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The package can be installed with Julia's package manager,
either by using the Pkg REPL mode (press ] to enter):
pkg> add HTTP
or by using Pkg functions
julia>using Pkg; Pkg.add("HTTP")
Project Status
The package has matured and is used in many production systems.
But as with all open-source software, please try it out and report your experience.
The package is tested against current Julia LTS (1.6), and current master on Linux, macOS, and Windows.
Contributing and Questions
Contributions are very welcome, as are feature requests and suggestions. Please open an
issue if you encounter any problems or would just like to ask a question.
Client Examples
HTTP.request
sends a HTTP Request Message and returns a Response Message.
r = HTTP.request("GET", "https://httpbin.org/ip")
println(r.status)
println(String(r.body))
HTTP.open
sends a HTTP Request Message and
opens an IO stream from which the Response can be read.
HTTP.open(:GET, "https://tinyurl.com/bach-cello-suite-1-ogg") do http
open(`vlc -q --play-and-exit --intf dummy -`, "w") do vlc
write(vlc, http)
endend
using HTTP
# HTTP.listen! and HTTP.serve! are the non-blocking versions of HTTP.listen/HTTP.serve
server = HTTP.serve!() do request::HTTP.Request@show request
@show request.method
@show HTTP.header(request, "Content-Type")
@show request.body
tryreturn HTTP.Response("Hello")
catch e
return HTTP.Response(400, "Error: $e")
endend# HTTP.serve! returns an `HTTP.Server` object that we can close manuallyclose(server)
WebSocket Examples
julia>using HTTP.WebSockets
julia> server = WebSockets.listen!("127.0.0.1", 8081) do ws
for msg in ws
send(ws, msg)
endend
julia> WebSockets.open("ws://127.0.0.1:8081") do ws
send(ws, "Hello")
s =receive(ws)
println(s)
end;
Hello
julia>close(server)