Discussion:
[ANN] httpx 0.14.0 released
(too old to reply)
Tiago Cardoso
2021-05-23 13:45:42 UTC
Permalink
httpx 0.14.0 has been released.

HTTPX.get("https://gitlab.com/honeyryderchuck/httpx
<https://gitlab.com/honeyryderchuck/httpx>")

HTTPX is an HTTP client library for the Ruby programming language.

Among its features, it supports:

* HTTP/2 and HTTP/1.x protocol versions
* Concurrent requests by default
* Simple and chainable API
* Proxy Support (HTTP(S), Socks4/4a/5)
* Simple Timeout System
* Lightweight by default (require what you need)

And also:

* Compression (gzip, deflate, brotli)
* Streaming Requests
* Authentication (Basic Auth, Digest Auth, AWS Sigv4)
* Expect 100-continue
* Multipart Requests
* Cookies
* HTTP/2 Server Push
* H2C Upgrade
* Automatic follow redirects
* International Domain Names
* GRPC

# 0.14.0

## Features

### GRPC plugin

A new plugin, `:grpc`, is now available. This plugin provides a simple DSL
to build GRPC services and performing calls using `httpx` under the hood.

Example:

```ruby
require "httpx"

grpc = HTTPX.plugin(:grpc)
helloworld_stub = grpc.build_stub("localhost:4545")
helloworld_svc = helloworld_stub.rpc(:SayHello, HelloRequest, HelloReply)
result = helloworld_svc.say_hello(HelloRequest.new(name: "Jack")) #=>
HelloReply: "Hello Jack"
```

You can read more about the `:grpc` plugin in the [wiki](
https://honeyryderchuck.gitlab.io/httpx/wiki/GRPC).

### :origin

A new `:origin` option is available. You can use it for setting a base URL
for subsequent relative paths on that session:

```ruby
HTTPX.get("/httpbin/get") #=> HTTPX::Error: invalid URI: /httpbin/get

httpbin = HTTPX.with(origin: "https://nghttp2.org")
httpbin.get("/httpbin/get") #=> #<Response:5420 HTTP/2.0 @status=200 ....
```

**Note!** The origin is **not** for setting base paths, i.e. if you pass it
a relative path, it'll be filtered out in subsequent requests
(`HTTPX.with(origin: "https://nghttp2.org/httpbin")` will still use only `"
https://nghttp2.org"`).

## Improvements

* setting an unexpected option will now raise an `HTTPX::Error` with an
helpful message, instead of a confusing `NoMethodError`:

```ruby
HTTPX.with(foo: "bar")
# before
#=> NoMethodError
# after
#=> HTTPX::Error: unknown option: foo

```

* `HTTPX::Options#def_option` (which can be used for setting custom plugin
options) can now be passed a full body string (where the argument is
`value`), although it still support the block form. This is the recommended
approach, as the block form is based on `define_method`, which would make
clients unusable inside ractors.

* Added support for `:wait_for_handshake` under the `http2_settings` option
(`false` by default). HTTP/2 connections complete the protocol handshake
before requests are sent. When this option is `true`, requests get send in
the initial payload, before the HTTP/2 connection is fully acknowledged.

* 441716a5ac0f7707211ebe0048f568cf0b759c3f: The `:stream` plugin has been
improved to start streaming the real response as methods are called
(instead of a completely separate synchronous one, which is definitely not
good):

```ruby
session = HTTPX.plugin(:stream)
response = session.get(build_uri("/stream/3"), stream: true)

# before
response.status # this could block indefinitely, if the request truly
streams infinitely.

# after
response.status # sends the request, and starts streaming the response
until status is available.
response.each {|chunk|...} # and now you can start yielding the chunks...
```


## Bugfixes

* fixed usage of the `:multipart` if `pathname` isn't loaded.
* fixed HTTP/2 trailers.
* fixed connection merges with the same origin, which was causing them to
be duplicated and breaking further usage. (#125)
* fixed repeated session callbacks on a connection, by ensure they're set
only once.
* fixed calculation of `content-length` for streaming or chunked compressed
requests.


## Chore

* using ruby base container images in CI instead.
* using truffleruby official container image.

# 0.13.2

## Improvements

`UDPSocket#sendmsg_nonblock` is now used in the native resolver.

## Bugfixes

Usage in Windows was buggy, resulting in `Errno::EINVAL` during DNS
resolving, when using the native resolver. This was due to a discrepancy
between `recvfrom` behaviour in WS Sockets and Linux Sockets. This was
fixed by making so the UDP socket never tries to receive before a DNS query
has been actually sent.

# 0.13.1

## Bugfixes

Rescue `Errno::EALREADY` on calls to `connect_nonblock(exception: false)`
(there are exceptions after all...).

Loading...