Packages
req
0.5.11
0.6.3
0.6.2
0.6.1
0.6.0
0.5.18
0.5.17
0.5.16
0.5.15
0.5.14
0.5.13
0.5.12
0.5.11
0.5.10
0.5.9
0.5.8
0.5.7
0.5.6
0.5.5
0.5.4
0.5.3
0.5.2
0.5.1
0.5.0
0.4.14
0.4.13
0.4.12
0.4.11
0.4.10
0.4.9
0.4.8
0.4.7
0.4.6
0.4.5
0.4.4
0.4.3
0.4.2
0.4.1
0.4.0
0.3.12
0.3.11
0.3.10
0.3.9
0.3.8
0.3.7
0.3.6
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.2
0.2.1
0.2.0
0.1.2
0.1.1
0.1.0
Req is a batteries-included HTTP client for Elixir.
Security advisory:
This version has known vulnerabilities.
View advisories
Current section
57 Versions
Jump to
Current section
57 Versions
Compare versions
10
files changed
+298
additions
-70
deletions
| @@ -1,8 +1,26 @@ | |
| 1 1 | # CHANGELOG |
| 2 2 | |
| 3 | + ## v0.5.11 (2025-06-23) |
| 4 | + |
| 5 | + * [`encode_body`]: Fix leading newline before multipart body |
| 6 | + |
| 7 | + * [`run_finch`]: Handle initial transport errors on `into: :self` |
| 8 | + |
| 9 | + * [`run_plug`]: Automatically parse request body |
| 10 | + |
| 11 | + * [`retry`]: Use jitter by default |
| 12 | + |
| 13 | + * [`Req.Request`]: Add [`Req.Request.put_option/3`]. |
| 14 | + |
| 15 | + * [`Req.Request`]: Add [`Req.Request.put_new_option/3`]. |
| 16 | + |
| 17 | + * [`Req.Request`]: Add [`Req.Request.merge_new_options/2`]. |
| 18 | + |
| 19 | + * [`Req.Test`]: Add [`Req.Test.redirect/2`]. |
| 20 | + |
| 3 21 | ## v0.5.10 (2025-03-21) |
| 4 22 | |
| 5 | - * [`Req`]: Add `Req.get_headers_list/1`. |
| 23 | + * [`Req`]: Add [`Req.get_headers_list/1`]. |
| 6 24 | |
| 7 25 | ## v0.5.9 (2025-03-17) |
| 8 26 | |
| @@ -1210,16 +1228,20 @@ See "Adapter" section in `Req.Request` module documentation for more information | |
| 1210 1228 | [`Req.cancel_async_request/1`]: https://hexdocs.pm/req/Req.html#merge/2 |
| 1211 1229 | [`Req.get_headers_list/1`]: https://hexdocs.pm/req/Req.html#get_headers_list/1 |
| 1212 1230 | |
| 1213 | - [`Req.Request`]: https://hexdocs.pm/req/Req.Request.html |
| 1214 | - [`Req.Request.new/1`]: https://hexdocs.pm/req/Req.Request.html#new/1 |
| 1215 | - [`Req.Request.run_request/1`]: https://hexdocs.pm/req/Req.Request.html#run_request/1 |
| 1216 | - [`Req.Request.get_option/3`]: https://hexdocs.pm/req/Req.Request.html#get_option/3 |
| 1217 | - [`Req.Request.get_option_lazy/2`]: https://hexdocs.pm/req/Req.Request.html#get_option_lazy/2 |
| 1218 | - [`Req.Request.fetch_option/2`]: https://hexdocs.pm/req/Req.Request.html#fetch_option/2 |
| 1219 | - [`Req.Request.fetch_option!/2`]: https://hexdocs.pm/req/Req.Request.html#fetch_option!/2 |
| 1220 | - [`Req.Request.delete_option/2`]: https://hexdocs.pm/req/Req.Request.html#delete_option/2 |
| 1221 | - [`Req.Request.drop_options/2`]: https://hexdocs.pm/req/Req.Request.html#drop_options/2 |
| 1222 | - [`Req.Request.update_private/4`]: https://hexdocs.pm/req/Req.Request.html#update_private/4 |
| 1231 | + [`Req.Request`]: https://hexdocs.pm/req/Req.Request.html |
| 1232 | + [`Req.Request.new/1`]: https://hexdocs.pm/req/Req.Request.html#new/1 |
| 1233 | + [`Req.Request.run_request/1`]: https://hexdocs.pm/req/Req.Request.html#run_request/1 |
| 1234 | + [`Req.Request.put_option/3`]: https://hexdocs.pm/req/Req.Request.html#put_option/3 |
| 1235 | + [`Req.Request.put_new_option/3`]: https://hexdocs.pm/req/Req.Request.html#put_new_option/3 |
| 1236 | + [`Req.Request.merge_options/2`]: https://hexdocs.pm/req/Req.Request.html#merge_options/2 |
| 1237 | + [`Req.Request.merge_new_options/2`]: https://hexdocs.pm/req/Req.Request.html#merge_new_options/2 |
| 1238 | + [`Req.Request.get_option/3`]: https://hexdocs.pm/req/Req.Request.html#get_option/3 |
| 1239 | + [`Req.Request.get_option_lazy/2`]: https://hexdocs.pm/req/Req.Request.html#get_option_lazy/2 |
| 1240 | + [`Req.Request.fetch_option/2`]: https://hexdocs.pm/req/Req.Request.html#fetch_option/2 |
| 1241 | + [`Req.Request.fetch_option!/2`]: https://hexdocs.pm/req/Req.Request.html#fetch_option!/2 |
| 1242 | + [`Req.Request.delete_option/2`]: https://hexdocs.pm/req/Req.Request.html#delete_option/2 |
| 1243 | + [`Req.Request.drop_options/2`]: https://hexdocs.pm/req/Req.Request.html#drop_options/2 |
| 1244 | + [`Req.Request.update_private/4`]: https://hexdocs.pm/req/Req.Request.html#update_private/4 |
| 1223 1245 | |
| 1224 1246 | [`Req.Response`]: https://hexdocs.pm/req/Req.Response.html |
| 1225 1247 | [`Req.Response.get_header/2`]: https://hexdocs.pm/req/Req.Response.html#get_response/2 |
| @@ -218,6 +218,7 @@ There are many packages that extend the Req library. To get yours listed here, s | |
| 218 218 | * [`req_github_oauth`] |
| 219 219 | * [`curl_req`] |
| 220 220 | * [`http_cookie`] |
| 221 | + * [`req_embed`] |
| 221 222 | |
| 222 223 | ## Presentations |
| 223 224 | |
| @@ -283,3 +284,4 @@ limitations under the License. | |
| 283 284 | [`Mix.install/2`]: https://hexdocs.pm/mix/Mix.html#install/2 |
| 284 285 | [`curl_req`]: https://github.com/derekkraan/curl_req |
| 285 286 | [`http_cookie`]: https://github.com/reisub/http_cookie |
| 287 | + [`req_embed`]: https://github.com/leandrocp/req_embed |
| @@ -2,9 +2,9 @@ | |
| 2 2 | [{<<"Changelog">>,<<"https://hexdocs.pm/req/changelog.html">>}, |
| 3 3 | {<<"GitHub">>,<<"https://github.com/wojtekmach/req">>}]}. |
| 4 4 | {<<"name">>,<<"req">>}. |
| 5 | - {<<"version">>,<<"0.5.10">>}. |
| 5 | + {<<"version">>,<<"0.5.11">>}. |
| 6 6 | {<<"description">>,<<"Req is a batteries-included HTTP client for Elixir.">>}. |
| 7 | - {<<"elixir">>,<<"~> 1.13">>}. |
| 7 | + {<<"elixir">>,<<"~> 1.14">>}. |
| 8 8 | {<<"files">>, |
| 9 9 | [<<"lib">>,<<"lib/req">>,<<"lib/req/response.ex">>,<<"lib/req/request.ex">>, |
| 10 10 | <<"lib/req/test">>,<<"lib/req/test/ownership.ex">>, |
| @@ -394,12 +394,12 @@ defmodule Req do | |
| 394 394 | |
| 395 395 | * A _module_ plug: a `module` name or a `{module, options}` tuple. |
| 396 396 | |
| 397 | - Finch options ([`run_finch`](`Req.Steps.run_finch/1`) step) |
| 397 | + Finch options ([`run_finch`](`Req.Steps.run_finch/1`) step), see `Finch.start_link/1` for options: |
| 398 398 | |
| 399 399 | * `:finch` - the Finch pool to use. Defaults to pool automatically started by `Req`. |
| 400 400 | |
| 401 401 | * `:connect_options` - dynamically starts (or re-uses already started) Finch pool with |
| 402 | - the given connection options: |
| 402 | + the given connection options (see `Mint.HTTP.connect/4` for options): |
| 403 403 | |
| 404 404 | * `:timeout` - socket connect timeout in milliseconds, defaults to `30_000`. |
| @@ -222,30 +222,41 @@ defmodule Req.Finch do | |
| 222 222 | defp finch_stream_into_self(req, finch_req, finch_name, finch_options) do |
| 223 223 | ref = Finch.async_request(finch_req, finch_name, finch_options) |
| 224 224 | |
| 225 | - {:status, status} = |
| 226 | - receive do |
| 227 | - {^ref, message} -> |
| 228 | - message |
| 229 | - end |
| 225 | + with {:status, status} <- recv_status(req, ref), |
| 226 | + {:headers, headers} <- recv_headers(req, ref) do |
| 227 | + # TODO: handle trailers |
| 228 | + headers = handle_finch_headers(headers) |
| 230 229 | |
| 231 | - headers = |
| 232 | - receive do |
| 233 | - {^ref, message} -> |
| 234 | - # TODO: handle trailers |
| 235 | - {:headers, headers} = message |
| 230 | + async = %Req.Response.Async{ |
| 231 | + pid: self(), |
| 232 | + ref: ref, |
| 233 | + stream_fun: &parse_message/2, |
| 234 | + cancel_fun: &cancel/1 |
| 235 | + } |
| 236 236 | |
| 237 | - handle_finch_headers(headers) |
| 238 | - end |
| 237 | + resp = Req.Response.new(status: status, headers: headers, body: async) |
| 238 | + {req, resp} |
| 239 | + end |
| 240 | + end |
| 239 241 | |
| 240 | - async = %Req.Response.Async{ |
| 241 | - pid: self(), |
| 242 | - ref: ref, |
| 243 | - stream_fun: &parse_message/2, |
| 244 | - cancel_fun: &cancel/1 |
| 245 | - } |
| 242 | + defp recv_status(req, ref) do |
| 243 | + receive do |
| 244 | + {^ref, {:status, status}} -> |
| 245 | + {:status, status} |
| 246 246 | |
| 247 | - resp = Req.Response.new(status: status, headers: headers, body: async) |
| 248 | - {req, resp} |
| 247 | + {^ref, {:error, exception}} -> |
| 248 | + {req, normalize_error(exception)} |
| 249 | + end |
| 250 | + end |
| 251 | + |
| 252 | + defp recv_headers(req, ref) do |
| 253 | + receive do |
| 254 | + {^ref, {:headers, headers}} -> |
| 255 | + {:headers, headers} |
| 256 | + |
| 257 | + {^ref, {:error, exception}} -> |
| 258 | + {req, normalize_error(exception)} |
| 259 | + end |
| 249 260 | end |
| 250 261 | |
| 251 262 | defp run_finch_request(finch_request, finch_name, finch_options) do |
| @@ -253,20 +264,8 @@ defmodule Req.Finch do | |
| 253 264 | {:ok, response} -> |
| 254 265 | Req.Response.new(response) |
| 255 266 | |
| 256 | - {:error, %Mint.TransportError{reason: reason}} -> |
| 257 | - %Req.TransportError{reason: reason} |
| 258 | - |
| 259 | - {:error, %Mint.HTTPError{module: Mint.HTTP1, reason: reason}} -> |
| 260 | - %Req.HTTPError{protocol: :http1, reason: reason} |
| 261 | - |
| 262 | - {:error, %Mint.HTTPError{module: Mint.HTTP2, reason: reason}} -> |
| 263 | - %Req.HTTPError{protocol: :http2, reason: reason} |
| 264 | - |
| 265 | - {:error, %Finch.Error{reason: reason}} -> |
| 266 | - %Req.HTTPError{protocol: :http2, reason: reason} |
| 267 | - |
| 268 267 | {:error, exception} -> |
| 269 | - exception |
| 268 | + normalize_error(exception) |
| 270 269 | end |
| 271 270 | end |
Loading more files…