|
1 | 1 | # Releases
|
2 | 2 |
|
| 3 | +## Unreleased |
| 4 | + |
| 5 | +### Support custom protocols with options |
| 6 | + |
| 7 | +{ruby Async::HTTP::Protocol} contains classes for specific protocols, e.g. {ruby Async::HTTP::Protocol::HTTP1} and {ruby Async::HTTP::Protocol::HTTP2}. It also contains classes for aggregating protocols, e.g. {ruby Async::HTTP::Protocol::HTTP} and {ruby Async::HTTP::Protocol::HTTPS}. They serve as factories for creating client and server instances. |
| 8 | + |
| 9 | +These classes are now configurable with various options, which are passed as keyword arguments to the relevant connection classes. For example, to configure an HTTP/1.1 protocol without keep-alive: |
| 10 | + |
| 11 | +```ruby |
| 12 | +protocol = Async::HTTP::Protocol::HTTP1.new(persistent: false, maximum_line_length: 32) |
| 13 | +endpoint = Async::HTTP::Endpoint.parse("http://localhost:9292", protocol: protocol) |
| 14 | +server = Async::HTTP::Server.for(endpoint) do |request| |
| 15 | + Protocol::HTTP::Response[200, {}, ["Hello, world"]] |
| 16 | +end.run |
| 17 | +``` |
| 18 | + |
| 19 | +Making a request to the server will now close the connection after the response is received: |
| 20 | + |
| 21 | +``` |
| 22 | +> curl -v http://localhost:9292 |
| 23 | +* Host localhost:9292 was resolved. |
| 24 | +* IPv6: ::1 |
| 25 | +* IPv4: 127.0.0.1 |
| 26 | +* Trying [::1]:9292... |
| 27 | +* Connected to localhost (::1) port 9292 |
| 28 | +* using HTTP/1.x |
| 29 | +> GET / HTTP/1.1 |
| 30 | +> Host: localhost:9292 |
| 31 | +> User-Agent: curl/8.12.1 |
| 32 | +> Accept: */* |
| 33 | +> |
| 34 | +* Request completely sent off |
| 35 | +< HTTP/1.1 200 OK |
| 36 | +< connection: close |
| 37 | +< content-length: 12 |
| 38 | +< |
| 39 | +* shutting down connection #0 |
| 40 | +Hello, world |
| 41 | +``` |
| 42 | + |
| 43 | +In addition, any line longer than 32 bytes will be rejected: |
| 44 | + |
| 45 | +``` |
| 46 | +curl -v http://localhost:9292/012345678901234567890123456789012 |
| 47 | +* Host localhost:9292 was resolved. |
| 48 | +* IPv6: ::1 |
| 49 | +* IPv4: 127.0.0.1 |
| 50 | +* Trying [::1]:9292... |
| 51 | +* Connected to localhost (::1) port 9292 |
| 52 | +* using HTTP/1.x |
| 53 | +> GET /012345678901234567890123456789012 HTTP/1.1 |
| 54 | +> Host: localhost:9292 |
| 55 | +> User-Agent: curl/8.12.1 |
| 56 | +> Accept: */* |
| 57 | +> |
| 58 | +* Request completely sent off |
| 59 | +* Empty reply from server |
| 60 | +* shutting down connection #0 |
| 61 | +curl: (52) Empty reply from server |
| 62 | +``` |
| 63 | + |
3 | 64 | ## v0.87.0
|
4 | 65 |
|
5 | 66 | ### Unify HTTP/1 and HTTP/2 `CONNECT` semantics
|
|
0 commit comments