Commit Graph

247 Commits

Author SHA1 Message Date
Andrew Kelley f333267782 update std.http.Server to new API
and rename std.io.BufferedWriter.writableSlice to writableSliceGreedy

and make writableSlice and writableArray advance the buffer end position

introduce std.io.BufferedWriter.writeSplatLimit but it's unimplemented
2025-07-01 16:35:27 -07:00
Andrew Kelley 98f463ad59 revert introduction of @errorCast in this branch 2025-07-01 16:35:27 -07:00
Jacob Young ffb0e283d7 build_runner: fix compile errors 2025-07-01 16:35:27 -07:00
Andrew Kelley a4fdda6ae0 std.io: redo Reader and Writer yet again
explicit error sets ahoy matey

delete some sus APIs from File that need to be reworked
2025-07-01 16:35:27 -07:00
Andrew Kelley 20a784f713 std: start converting networking stuff to new reader/writer 2025-07-01 16:35:27 -07:00
Jacob Young a21e7ab64f build_runner: port to new std.io.BufferedWriter API 2025-07-01 16:35:26 -07:00
Andrew Kelley 646454beb5 maybe it's better to track bytes written in BufferedWriter 2025-07-01 16:35:26 -07:00
Andrew Kelley 57e1fc29d2 reader interface vecs and bufferedwriter arraylist 2025-07-01 16:35:26 -07:00
Andrew Kelley 4aed226e07 zig fmt compiling 2025-07-01 16:35:26 -07:00
Andrew Kelley 5ada2e3937 std.http tests passing with updated writer API
fix splat implementation in std.fs.File

update http.Client, with caveats:
 * TODO: only 1 underlying write call
 * TODO: don't rely on max_buffers_len exceeding the caller
 * TODO: handle splat

update net.Stream API. also make it use WSASend on windows
2025-07-01 16:35:26 -07:00
Andrew Kelley 716b4489be update more of the std lib to new API 2025-07-01 16:35:26 -07:00
Andrew Kelley fced9467e8 std ArrayList unit tests passing 2025-07-01 16:35:26 -07:00
Jacob Young 1f6f8b0ffe x86_64: implement integer @reduce(.Add) 2025-05-28 15:10:22 -04:00
Shun Sakai 5fc4448e45 chore(std.mem): Rename trimLeft and trimRight
Rename `trimLeft` to `trimStart`, and `trimRight` to `trimEnd`.
`trimLeft` and `trimRight` functions remain as deprecated aliases for
these new names.
2025-04-27 18:03:59 +09:00
Andrew Kelley 337e1109f5 std.DoublyLinkedList: remove length tracking
this is trivial to tack on, and in my experience it is rarely wanted.
2025-04-03 15:57:35 -07:00
Kuwazy 6b6dc1cd3a Added check for HTTP version and GET method when upgrading WebSocket to comply with RFC 6455. (#23332) 2025-03-25 15:00:50 +01:00
Elijah M. Immer 1f92b394e9 lib/std/http/Client.zig: Ignore empty proxy environment variables (#23223)
This fixes #21032 by ignoring proxy environment variables that are
empty.
2025-03-14 21:20:42 +01:00
Andrew Kelley eb3c7f5706 zig build fmt 2025-02-22 17:09:20 -08:00
87flowers 8469a44c9c std/http/Client: Remove TODO comments on indentation 2025-02-22 17:09:20 -08:00
Andrew Kelley df1fa36feb Revert "std.http.Server: add Request.getHeader() function (#21625)"
This reverts commit 21823d1b5d.

It's a bad API that could easily lead to O(N^2) logic.
2025-01-27 11:13:56 -08:00
dbubel 21823d1b5d std.http.Server: add Request.getHeader() function (#21625) 2025-01-27 17:58:05 +00:00
Jacob Young 7c713251ca x86_64: looped instructions 2025-01-16 20:42:08 -05:00
Jacob Young 9373abf7f7 std.http.Client: change ssl key log creation permission bits
This is the same mode used by openssh for private keys.  This does not
change the mode of an existing file, so users who need something
different can pre-create the file with their designed permissions or
change them after the fact, and running another process that writes to
the key log will not change it back.
2024-11-07 20:56:33 -05:00
Jacob Young de53e6e4f2 std.crypto.tls: improve debuggability of encrypted connections
By default, programs built in debug mode that open a https connection
will append secrets to the file specified in the SSLKEYLOGFILE
environment variable to allow protocol debugging by external programs.
2024-11-07 20:25:26 -05:00
Jacob Young c2a779ae79 std.crypto.tls: implement TLSv1.2 2024-11-07 20:25:26 -05:00
Andrew Kelley 075ec55552 disable failing test
tracked by #21457
2024-09-19 18:20:22 -07:00
Linus Groh e17dfb9da0 std.http.WebSocket: Make 'upgrade: websocket' check case-insensitive
I've seen implementations in the wild that send 'Upgrade: WebSocket',
which currently fails the handshake.

From https://datatracker.ietf.org/doc/html/rfc6455:

"If the response lacks an |Upgrade| header field or the |Upgrade| header
field contains a value that is not an ASCII case-insensitive match for
the value "websocket", the client MUST _Fail the WebSocket Connection_."
2024-09-12 20:02:19 -07:00
Andrew Kelley b9fd0eeca6 add std.http.WebSocket 2024-08-07 00:48:32 -07:00
Nameless aecd9cc6d1 std.posix.iovec: use .base and .len instead of .iov_base and .iov_len 2024-04-28 00:20:30 -07:00
Travis Staloch 8af59d1f98 ComptimeStringMap: return a regular struct and optimize
this patch renames ComptimeStringMap to StaticStringMap, makes it
accept only a single type parameter, and return a known struct type
instead of an anonymous struct.  initial motivation for these changes
was to reduce the 'very long type names' issue described here
https://github.com/ziglang/zig/pull/19682.

this breaks the previous API.  users will now need to write:
`const map = std.StaticStringMap(T).initComptime(kvs_list);`

* move `kvs_list` param from type param to an `initComptime()` param
* new public methods
  * `keys()`, `values()` helpers
  * `init(allocator)`, `deinit(allocator)` for runtime data
  * `getLongestPrefix(str)`, `getLongestPrefixIndex(str)` - i'm not sure
     these belong but have left in for now incase they are deemed useful
* performance notes:
  * i posted some benchmarking results here:
    https://github.com/travisstaloch/comptime-string-map-revised/issues/1
  * i noticed a speedup reducing the size of the struct from 48 to 32
    bytes and thus use u32s instead of usize for all length fields
  * i noticed speedup storing KVs as a struct of arrays
  * latest benchmark shows these wall_time improvements for
    debug/safe/small/fast builds: -6.6% / -10.2% / -19.1% / -8.9%. full
    output in link above.
2024-04-22 15:31:41 -07:00
Andrew Kelley 0a3dff8125 Revert "std.http.Client: always omit port when it matches default"
This reverts commit db0a42b558c64eac2b4e41d02b078931b0c63af8, but keeps
the changes to std/Uri.zig.
2024-04-12 22:37:07 -07:00
Andrew Kelley 6deb3e3986 std.http.Client: always omit port when it matches default
This makes the host http header have the port if and only if it differs
from the defaults based on the protocol.

This is an alternate implementation that closes #19624.
2024-04-12 22:37:07 -07:00
Andrew Kelley 419753f45e std.http.Client: pass port to server based on user input
This makes the host http header have the port if and only if the URI
provided by the API user included it.

Closes #19624
2024-04-12 22:37:07 -07:00
Jacob Young c4587dc9f4 Uri: propagate per-component encoding
This allows `std.Uri.resolve_inplace` to properly preserve the fact
that `new` is already escaped but `base` may not be.  I originally tried
just moving `raw_uri` around, but it made uri resolution unmanagably
complicated, so I instead added per-component information to `Uri` which
allows extra allocations to be avoided when constructing uris with
components from different sources, and in some cases, deferring the work
all the way to when the uri is printed, where an allocator may not even
be needed.

Closes #19587
2024-04-10 02:11:54 -07:00
Jacob Young eb723a4070 Update uses of @fieldParentPtr to use RLS 2024-03-30 20:50:48 -04:00
Jacob Young e409afb79b Update uses of @fieldParentPtr to pass a pointer type 2024-03-30 20:50:48 -04:00
Andrew Kelley cd62005f19 extract std.posix from std.os
closes #5019
2024-03-19 11:45:09 -07:00
Tristan Ross 6067d39522 std.builtin: make atomic order fields lowercase 2024-03-11 07:09:10 -07:00
Andrew Kelley 671c2acf47 Merge pull request #19094 from truemedian/std-http-fields
std.http: fix http field parsing
2024-03-02 14:34:43 -08:00
Roman Frołow 155f5274ff typo: http_proxy -> https_proxy 2024-03-01 17:41:14 -08:00
Nameless e62b0773cc std.http: add tests against regressions for conforming fields 2024-02-28 15:12:44 -06:00
Nameless 81713f20a6 std.http: header whitespace is optional, and not part of value 2024-02-28 15:12:43 -06:00
Nameless 69bcdbefd0 std.http: clear confusing trailer check, add sanity check for invalid field name 2024-02-28 15:12:41 -06:00
Jacob Young 4e2570baaf http: fix fetching a github release
* Support different keep alive defaults with different http versions.
 * Fix incorrect usage of `copyBackwards`, which copies in a backwards
   direction allowing data to be moved forward in a buffer, not
   backwards in a buffer.
2024-02-26 20:11:43 -08:00
Andrew Kelley 1b79a42da0 std.http.Server: fix use case of streaming both reading and writing 2024-02-26 13:42:01 -08:00
Andrew Kelley 032c2ee9bc std.http.Client: fix UAF when handling redirects
closes #19071
2024-02-26 01:01:16 -08:00
Andrew Kelley aa39e98d90 Merge pull request #19077 from Techatrix/http-header-parse
http: check for empty header name instead of value
2024-02-25 15:27:12 -08:00
Techatrix a07218cc43 http: handle header fields with empty value 2024-02-25 12:07:13 +01:00
Andrew Kelley f9bf4d1d60 std.http tests: wait for server response
This avoids a race that can make the unit test fail
2024-02-24 04:16:21 -07:00
Andrew Kelley 653d4158cd std.http.Server: expose arbitrary HTTP headers
Ultimate flexibility, just be sure to destroy the correct amount of
information when looking at them.
2024-02-23 02:58:02 -07:00