Commit graph

150 commits

Author SHA1 Message Date
Jacob Young
82b37ea024 http: support basic access authentication 2024-01-31 12:05:12 +01:00
Nameless
a7dbc57a35 std.http.Client: read response messages with no length until eof 2024-01-18 15:43:58 -08:00
Nameless
b723296e1f std.http: add missing documentation and a few examples 2024-01-13 18:51:38 -08:00
mlugg
51595d6b75
lib: correct unnecessary uses of 'var' 2023-11-19 09:55:07 +00:00
Jacob Young
509be7cf1f x86_64: fix std test failures 2023-11-03 23:18:21 -04:00
Jordyfel
61861ef395 std.http: account for renames in docs 2023-11-01 14:46:00 +02:00
Andrew Kelley
3fc6fc6812 std.builtin.Endian: make the tags lower case
Let's take this breaking change opportunity to fix the style of this
enum.
2023-10-31 21:37:35 -04:00
Nameless
87735e4dae std.http.Client: add proxy scheme guessing, fix typo
This adds scheme guessing when loading proxies, such that
`HTTP_PROXY=127.0.0.1` and such are valid now and it behaves identically
to `HTTP_PROXY=http://127.0.0.1`. Additionally fixed a typo that was
causing loadDefaultProxies to never populate the https_proxy.
2023-10-27 03:42:33 -04:00
Jacob Young
8f69e977f1 x86_64: implement 128-bit builtins
* `@clz`
 * `@ctz`
 * `@popCount`
 * `@byteSwap`
 * `@bitReverse`
 * various encodings used by std
2023-10-23 22:42:18 -04:00
Andrew Kelley
b82459fa43
Merge pull request #17407 from truemedian/http-ng
std.http: more proxy support, buffer writes, tls toggle
2023-10-22 17:48:03 -04:00
Jacob Young
27fe945a00 Revert "Revert "Merge pull request #17637 from jacobly0/x86_64-test-std""
This reverts commit 6f0198cadb.
2023-10-22 15:46:43 -04:00
Andrew Kelley
6f0198cadb Revert "Merge pull request #17637 from jacobly0/x86_64-test-std"
This reverts commit 0c99ba1eab, reversing
changes made to 5f92b070bf.

This caused a CI failure when it landed in master branch due to a
128-bit `@byteSwap` in std.mem.
2023-10-22 12:16:35 -07:00
Nameless
93e1f8c8e5
std.http.Client: documentaion fixes 2023-10-21 20:53:00 -05:00
Nameless
dd010e9e90
std.http.Client: ignore unknown proxies, fix basic proxy auth 2023-10-21 20:53:00 -05:00
Nameless
7dd3099519
std.http: fix crashes found via fuzzing 2023-10-21 20:52:59 -05:00
Nameless
363d0ee5e1
std.http: rename start->send and request->open to be more inline with operation 2023-10-21 20:52:59 -05:00
Nameless
544ed34d99
std.http.Server: improve documentation, do -> start
Response.do was renamed to Response.start to mimic the
naming scheme in http.Client
2023-10-21 20:52:59 -05:00
Nameless
d4cf8ea0b7
std.http.Client: improve documentation 2023-10-21 20:52:59 -05:00
Nameless
c523b5421b
std.http: make encoding fields non-null, store as enum variant 2023-10-21 20:52:59 -05:00
Nameless
16f89eab45
std.http.Client: make transfer-encoding priority over content-length as per spec 2023-10-21 20:52:59 -05:00
Nameless
0eef21d8ec
std.http.Client: add option to disable https
std_options.http_connection_pool_size removed in favor of

```
client.connection_pool.resize(client.allocator, size);
```

std_options.http_disable_tls will remove all https capability from
std.http when true. Any https request will error with
`error.TlsInitializationFailed`.

Solves #17051.
2023-10-21 20:52:58 -05:00
Nameless
e1c37f70d4
std.http.Client: store *Connection instead of a pool node, buffer writes 2023-10-21 20:52:58 -05:00
Nameless
1afeada2d9
std.http.Client: enhance proxy support
adds connectTunnel to form a HTTP CONNECT tunnel to the desired host.
Primarily implemented for proxies, but like connectUnix may be called by
any user.

adds loadDefaultProxies to load proxy information from common
environment variables (http_proxy, HTTP_PROXY, https_proxy, HTTPS_PROXY,
all_proxy, ALL_PROXY).
- no_proxy and NO_PROXY are currently unsupported.

splits proxy into http_proxy and https_proxy, adds headers field for
arbitrary headers to each proxy.
2023-10-21 20:52:58 -05:00
Jacob Young
2e6e39a700 x86_64: fix bugs and disable erroring tests 2023-10-21 10:55:41 -04:00
Emil Lerch
fcca3cd1a3
std.http: introduce options to http client to allow for raw uris
Addresses #17015 by introducing a new startWithOptions. The only option is currently is a flag
to use the provided URI as is, without modification when passed to the server. Normally, this
is not needed nor desired. However, some REST APIs may have requirements that cannot be satisfied
with the default handling.
2023-09-28 14:16:39 +03:00
Chris Burgess
1c726bcb32
std.http: add identity to content encodings (#16493)
Some servers will respond with the identity encoding, meaning no
encoding, especially when responding to range-get requests. Adding the
identity encoding stops the header parser from failing when it
encounters this.
2023-09-26 17:16:40 -04:00
Jan Weidner
c8ba5839f7
std.http.Client: add note about resource management 2023-09-25 12:17:11 +03:00
Nameless
4689d93cb2
std.http: allow for arbitrary http methods 2023-08-30 13:05:45 -05:00
Nameless
3817c7382b
std.http: connectUnix return Unsupported on targets without unix sockets 2023-08-29 21:42:53 -05:00
Nameless
aa090a49d9
std.http: handle expect:100-continue and continue responses 2023-08-29 21:42:53 -05:00
Nameless
5d40338f21
std.http: add Client.fetch and improve redirect logic 2023-08-29 21:42:53 -05:00
Jay Petacat
ff61c42879 std: Rename TailQueue to DoublyLinkedList
`TailQueue` was implemented as a doubly-linked list, but named after an
abstract data type. This was inconsistent with `SinglyLinkedList`, which
can be used to implement an abstract data type, but is still named after
the implementation. Renaming `TailQueue` to `DoublyLinkedList` improves
consistency between the two type names, and should help discoverability.

`TailQueue` is now a deprecated alias of `DoublyLinkedList`.

Related to issues #1629 and #8233.
2023-08-27 20:57:46 -07:00
Nameless
b9fc0d2908
std.http: fix leaked connections (#16341)
The early return in pool release was causing leaked connections.
Closes #16282.
2023-07-07 20:08:19 +00:00
mlugg
f26dda2117 all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:

* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
2023-06-24 16:56:39 -07:00
Piotr Sarna
438d680913 http: fix getting Transfer-Encoding value
The 'Content-Length' header was inspected by mistake,
which makes it effectively impossible to use chunked
Transfer-Encoding when using the http client.

Tested locally with a HTTP server - data is properly sent
with POST method and the proper encoding declared, after the fix.
2023-06-22 11:44:46 +03:00
Eric Joldasov
50339f595a all: zig fmt and rename "@XToY" to "@YFromX"
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-19 12:34:42 -07:00
Mizuochi Keita
729a051e9e std.http: Fix segfault while redirecting
Make to avoid releasing request's connection twice.
Change the `Request.connection` field optional. This field is null while the connection is released.

Fixes #15965
2023-06-17 21:58:33 -07:00
Xavier Bouchoux
67b3e07260 zlib: naming convention
Adress review comments from https://github.com/ziglang/zig/pull/13977
by using the same naming convention as zstd.

And by using `finish()` instead of `close()` for the finalisation of the compressed stream.
rationale:
  - it is not the same as how close() is usually used, since it must be called to flush and write the final bytes. And as such it may fail.
  - it is not the same `flush` in the deflate code, which allows to keep writting more bytes later, and doesn't write the final checksum.
  - it is the same name as used in the original zlib library (Z_FINISH)

Also, use a packed struct for the header, which seems a better fit.
2023-06-17 14:08:05 -07:00
Andrew Kelley
629f0d23b5
Merge pull request #15579 from squeek502/mem-delimiters
Split `std.mem.split` and `tokenize` into `sequence`, `any`, and `scalar` versions
2023-06-03 13:51:02 -07:00
Nameless
23ccff9cce
std.http.Server: collapse BufferedConnection into Connection 2023-06-01 13:44:00 -05:00
Nameless
0e5e6cb10c
std.http: add TlsAlert descriptions so that they can at least be viewed in err return traces 2023-06-01 13:43:55 -05:00
Nameless
8136123aa7
std.http.Client: collapse BufferedConnection into Connection 2023-06-01 13:43:23 -05:00
Ryan Liptak
2129f28953 Update all std.mem.split calls to their appropriate function
Everywhere that can now use `splitScalar` should get a nice little performance boost.
2023-05-13 13:45:05 -07:00
Ryan Liptak
815e53b147 Update all std.mem.tokenize calls to their appropriate function
Everywhere that can now use `tokenizeScalar` should get a nice little performance boost.
2023-05-13 13:45:04 -07:00
Nameless
9017d758b9
std.http: use larger read buffer to hit faster tls code 2023-05-06 21:35:17 -05:00
Nameless
1b3ebfefd8
fix keepalive and large buffered writes 2023-05-06 21:35:16 -05:00
Nameless
7b09629388
std.http: buffer writes 2023-05-06 21:35:16 -05:00
Nameless
71c228fe65
std.http: add simple standalone http tests, add state check for http server 2023-05-06 21:35:15 -05:00
Andrew Kelley
125221cce9 std: update to use @memcpy directly 2023-04-28 13:24:43 -07:00
Nameless
7285eedcd2 std.http: do -> wait, fix redirects 2023-04-26 00:02:55 -07:00