Skip to content

Commit f4d251c

Browse files
committed
Release notes.
1 parent ad3ae56 commit f4d251c

File tree

4 files changed

+72
-7
lines changed

4 files changed

+72
-7
lines changed

lib/async/http/protocol/configurable.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def client(peer, **options)
2525

2626
def server(peer, **options)
2727
options = @options.merge(options)
28-
@protocol.server(peer, options)
28+
@protocol.server(peer, **options)
2929
end
3030

3131
def names

lib/async/http/protocol/defaulton.rb

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@ module Protocol
99
# This module provides a default instance of the protocol, which can be used to create clients and servers. The name is a play on "Default" + "Singleton".
1010
module Defaulton
1111
def self.extended(base)
12-
base.const_set(:DEFAULT, base.new)
12+
base.instance_variable_set(:@default, base.new)
1313
end
1414

15-
# The default instance of the protocol.
16-
def default
17-
self::DEFAULT
18-
end
15+
attr_accessor :default
1916

2017
# Create a client for an outbound connection, using the default instance.
2118
def client(peer, **options)

releases.md

+61
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,66 @@
11
# Releases
22

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+
364
## v0.87.0
465

566
### Unify HTTP/1 and HTTP/2 `CONNECT` semantics

test/async/http/protocol/http.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@
88
require "async/http/a_protocol"
99

1010
describe Async::HTTP::Protocol::HTTP do
11+
let(:protocol) {subject.default}
12+
13+
with ".default" do
14+
it "has a default instance" do
15+
expect(subject.default).to be_a Async::HTTP::Protocol::HTTP
16+
end
17+
end
18+
1119
with "#protocol_for" do
12-
let(:protocol) {subject::DEFAULT}
1320
let(:buffer) {StringIO.new}
1421

1522
it "it can detect http/1.1" do

0 commit comments

Comments
 (0)