• Stars
    star
    624
  • Rank 69,301 (Top 2 %)
  • Language
    Julia
  • License
    Other
  • Created over 7 years ago
  • Updated 16 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

HTTP for Julia

HTTP

HTTP client and server functionality for Julia

Documentation Build Status

Installation

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", "http://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)
    end
end

Server Examples

HTTP.Servers.listen:

The server will start listening on 127.0.0.1:8081 by default.

using HTTP

# start a blocking server
HTTP.listen() do http::HTTP.Stream
    @show http.message
    @show HTTP.header(http, "Content-Type")
    while !eof(http)
        println("body data: ", String(readavailable(http)))
    end
    HTTP.setstatus(http, 404)
    HTTP.setheader(http, "Foo-Header" => "bar")
    HTTP.startwrite(http)
    write(http, "response body")
    write(http, "more response body")
end

HTTP.Handlers.serve:

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
   try
       return HTTP.Response("Hello")
   catch e
       return HTTP.Response(400, "Error: $e")
   end
end
# HTTP.serve! returns an `HTTP.Server` object that we can close manually
close(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)
        end
    end

julia> WebSockets.open("ws://127.0.0.1:8081") do ws
           send(ws, "Hello")
           s = receive(ws)
           println(s)
       end;
Hello

julia> close(server)

More Repositories

1

Mux.jl

Middleware for Julia
Julia
273
star
2

JuliaWebAPI.jl

Julia package for deploying APIs
Julia
188
star
3

GitHub.jl

A Julia package for interfacing with GitHub
Julia
169
star
4

WebSockets.jl

A WebSockets library for Julia
Julia
156
star
5

Gumbo.jl

Julia wrapper around Google's gumbo C library for parsing HTML
Julia
151
star
6

HttpServer.jl

DEPRECATED! Basic, non-blocking HTTP server in Julia.
Julia
133
star
7

Requests.jl

[DEPRECATED in favor of https://github.com/JuliaWeb/HTTP.jl] HTTP for Julians
Julia
120
star
8

Hyperscript.jl

Hyperscript: A lightweight DOM representation for Julia
Julia
94
star
9

LibCURL.jl

Julia wrapper for libcurl
Julia
33
star
10

HttpCommon.jl

Types and helper functions for dealing with the HTTP in Julia
Julia
31
star
11

GeoIP.jl

A Julia package to estimate the geographic location of IP addresses
Julia
25
star
12

URIs.jl

URI parsing in Julia
Julia
25
star
13

Retry.jl

Macros for simplified exception handling: @repeat try, @retry, @delay_retry, @protected try, @ignore.
Julia
25
star
14

HTTPClient.jl

DEPRECATED, USE HTTP.jl INSTEAD
Julia
17
star
15

URIParser.jl

Uniform Resource Identifier (URI) parser in Julia
Julia
17
star
16

HttpParser.jl

Deprecated! Julia wrapper for joyent/http-parser
Julia
14
star
17

GitForge.jl

Unified interface for interacting with Git forges
Julia
12
star
18

IPNets.jl

IPv4 / IPv6 network abstractions for Julia
Julia
11
star
19

MIMEs.jl

MIME information: filetype, encoding, gzip
Julia
9
star
20

OpenSSL.jl

Julia
9
star
21

GnuTLS.jl

Transport Level Security for Julia Streams provided by GnuTLS
Julia
8
star
22

UAParser.jl

Parse user-agent strings into components
Julia
7
star
23

Roadmap

Discussion and planning for JuliaWeb packages
7
star
24

LibSSH.jl

A Julia wrapper for libssh.
Julia
6
star
25

URITemplate.jl

RFC6570 URI templates for Julia
Julia
4
star
26

TransportLayerSecurity.jl

TLS abstraction package for Julia
Julia
2
star
27

HTTP2.jl

Julia
1
star
28

LibCURLBuilder

Julia
1
star
29

MbedTLSBuilder

Julia
1
star
30

GumboBuilder

Deprecated. Now built using https://github.com/JuliaPackaging/Yggdrasil/tree/master/G/Gumbo
Julia
1
star
31

TLSClient.jl

WIP: Julia interface for OS TLS/TCP (mac/iOS: SecureTransport, Linux: OpenSSL, Win: Schannel...)
1
star