# std.http.Client: support HTTP redirects · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/8248fdbbdb88cc861c3d02a26ec4a214df3f9a1e)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 8248fdbbdb88cc861c3d02a26ec4a214df3f9a1e

Requested commit: 8248fdbbdb88cc861c3d02a26ec4a214df3f9a1e

Commit: 8248fdbbdb88cc861c3d02a26ec4a214df3f9a1e

Tree: 1064a9a537b57cf83fe9a496594e831eff188585

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
std.http.Client: support HTTP redirects

 * std.http.Status.Class: add a "nonstandard" enum tag. Instead of
   having `class` return an optional value, it can potentially return
   nonstandard.
 * extract out std.http.Client.Connection from std.http.Client.Request
   - this code abstracts over plain/TLS only
   - this is the type that will potentially be stored in a client's LRU
     connection map
 * introduce two-staged HTTP header parsing
   - API users can rely on a heap-allocated buffer with a maximum limit,
     which defaults to 16 KB, or they can provide a static buffer that
     is borrowed by the Request instance.
   - The entire HTTP header is buffered because there are strings in
     there and they must be accessed later, such as with the case of
     HTTP redirects.
   - When buffering the HTTP header, the parser only looks for the
     \r\n\r\n pattern. Further validation is done later.
   - After the full HTTP header is buffered, it is parsed into
     components such as Content-Length and Location.
 * HTTP redirects are handled, with a maximum redirect count option that
   defaults to 3.
   - Connection: close is always used for now; implementing keep-alive
     connections and an LRU connection pool in std.http.Client is a task
     for another day.

see #2007

```

## Parents

- [079f62881ee8291e1b290848c1081c822ea8389f](https://git.cafe/gitcafe/zig/commit/079f62881ee8291e1b290848c1081c822ea8389f?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/8248fdbbdb88cc861c3d02a26ec4a214df3f9a1e?format=markdown)
