120 Commits

Author SHA1 Message Date
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
ddef683fcb
std.http.Server: responses to HEAD not allowed to have a payload 2023-08-29 21:42:54 -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
jaina heartles
b835fd90ce std.http.Server: use correct header for Transfer-Encoding 2023-08-10 17:45:37 -07:00
jim price
59322963ce Fix the http.Server test and add it to the set of tests in http.zig 2023-07-23 13:58:34 -07:00
antlilja
b463e429b8 Remove len parameter from splat in standard lib 2023-07-12 15:35:57 -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
Ed Yu
8dcb4a3dc4 std.http: fix the http.Client.wait() hanging when there is 1 more byte left 2023-06-23 20:18:24 +02: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
r00ster91
2593156068 migration: std.math.{min, min3, max, max3} -> @min & @max 2023-06-16 13:44:09 -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
Ali Chraghi
3db3cf7790 std.sort: add pdqsort and heapsort 2023-05-23 17:55:59 -07: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
5f219a2d11
std.http.Server: give Response access to their own allocator
* This makes it easier for threaded servers to use a different allocator
  for each request.
2023-05-06 21:35:16 -05:00
Nameless
7b09629388
std.http: buffer writes 2023-05-06 21:35:16 -05:00
Nameless
533049fdd8
std.http.Server: use enum for reset state instead of bool 2023-05-06 21:35:15 -05:00
Nameless
6513eb4696
std.http.Server: use client recommendation for keepalive 2023-05-06 21:35:15 -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
Ryo Ota
bba90b8863 fix HTTP server to handle a chunked transfer coding request 2023-04-24 15:36:35 -07:00
Andrew Kelley
1d1255b433
Merge pull request #15416 from squeek502/http-response-headers-undefined
std.http: Always initialize `response.headers` in Client.request
2023-04-24 15:15:17 -07:00
Ryan Liptak
0488c3cb52 std.http: Always initialize response.headers in Client.request
Before this change, if a request errored before getting its `response.headers` initialized, then it would attempt to `deinit` `response.headers` which would still be `undefined`. Since all locations that set `response.headers` use the same code, it can just be done upfront in `request` instead.

Closes #15380
2023-04-23 15:33:23 -07:00
Ryan Liptak
1acb3162b7 http.Headers: Add clearAndFree and clearRetainingCapacity 2023-04-23 15:33:05 -07:00
Ryo Ota
afebef2465 create std.http.Server.Response.deinit to handle keepalive connections 2023-04-21 10:17:16 +09:00
Ryo Ota
06763c4c8c move the HTTP test to lib/std/http/test.zig 2023-04-21 09:51:23 +09:00
Ryo Ota
39c0c24b56 fix memory leaks and add an HTTP test 2023-04-21 02:35:38 +09:00
Ryo Ota
0f4f607814 fix http client build error 2023-04-20 22:19:00 +09:00
Ryo Ota
d80e6ca5a6 std.http: add missing InvalidTrailers to ReadError 2023-04-20 12:35:26 +03:00
Nameless
a23c8662b4
std.http: pass Method to request directly, parse trailing headers 2023-04-18 10:28:53 -05:00
Nameless
e65cbff94d
std.http: use 'Field' to describe an individual header 2023-04-17 19:16:06 -05:00
Nameless
85221b4e97
std.http: curate some Server errors, fix reading chunked bodies 2023-04-17 19:16:01 -05:00
Nameless
134294230a
std.http: add Headers 2023-04-17 19:15:55 -05:00
Nameless
96533b1289
std.http: very basic http client proxy 2023-04-17 19:14:48 -05:00