starting notes on the next minor version

This commit is contained in:
HoneyryderChuck 2020-10-06 16:44:35 +01:00
parent 978a5ffa22
commit b67c5d53e0
2 changed files with 41 additions and 3 deletions

View File

@ -0,0 +1,38 @@
# 0.9.0
## Features
### Multiple requests with specific options
You can now pass a third element to the "request element" of an array to `.request`.
```ruby
requests = [
[:post, "https://url/post", { form: { foo: "bar" } }],
[:post, "https://url/post", { form: { foo: "bar2" } }]
]
HTTPX.request(requests)
# or, if you want to pass options common to all requests
HTTPX.request(requests, max_concurrent_requests: 1)
```
### HTTPX::Session#build_request
`HTTPX::Session::build_request` is now public API from a session. You can now build requests before you send them. These request objects are still considered somewhat "internal", so consider them immutable and **do not rely on its API**. Just pass them forward.
Note: this API is only available for instantiated session, so there is no `HTTPX.build_request`.
```ruby
HTTPX.wrap do |http|
requests = [
http.build_request(:post, "https://url/post", { form: { foo: "bar" } }),
http.build_request(:post, "https://url/post", { form: { foo: "bar2" } })
]
http.request(requests)
# or, if you want to pass options common to all requests
http.request(requests, max_concurrent_requests: 1)
end
```

View File

@ -6,9 +6,9 @@ include HTTPX
URLS = %w[http://nghttp2.org/httpbin/post] * 102
$HTTPX_DEBUG = true
client = Client.new
requests = URLS.map { |url| client.request(:post, url, json: {"bang" => "bang"}) }
responses = client.send(*requests)
client = Session.new
requests = URLS.map { |url| client.build_request(:post, url, json: {"bang" => "bang"}) }
responses = client.request(*requests)
responses.each do |res|
puts "status: #{res.status}"