28690 Commits

Author SHA1 Message Date
Andrew Kelley
4d401e6159 std.http: remove Headers API
I originally removed these in 402f967ed5339fa3d828b7fe1d57cdb5bf38dbf2.
I allowed them to be added back in #15299 because they were smuggled in
alongside a bug fix, however, I wasn't kidding when I said that I wanted
to take the design of std.http in a different direction than using this
data structure.

Instead, some headers are provided via explicit field names populated
while parsing the HTTP request/response, and some are provided via
new fields that support passing extra, arbitrary headers.

This resulted in simplification of logic in many places, as well as
elimination of the possibility of failure in many places. There is
less deinitialization code happening now.

Furthermore, it made it no longer necessary to clone the headers data
structure in order to handle redirects.

http_proxy and https_proxy fields are now pointers since it is common
for them to be unpopulated.

loadDefaultProxies is changed into initDefaultProxies to communicate
that it does not actually load anything from disk or from the network.
The function now is leaky; the API user must pass an already
instantiated arena allocator. Removes the need to deinitialize proxies.

Before, proxies stored arbitrary sets of headers. Now they only store
the authorization value.

Removed the duplicated code between https_proxy and http_proxy. Finally,
parsing failures of the environment variables result in errors being
emitted rather than silently ignoring the proxy.

error.CompressionNotSupported is renamed to
error.CompressionUnsupported, matching the naming convention from all
the other errors in the same set.

Removed documentation comments that were redundant with field and type
names.

Disabling zstd decompression in the server for now; see #18937.

I found some apparently dead code in src/Package/Fetch/git.zig. I want
to check with Ian about this.

I discovered that test/standalone/http.zig is dead code, it is only
being compiled but not being run. Furthermore it hangs at the end if you
run it manually. The previous commits in this branch were written under
the assumption that this test was being run with
`zig build test-standalone`.
2024-02-23 02:37:11 -07:00
Andrew Kelley
f46447e6a1 std.http.Client.fetch: add redirect behavior to options 2024-02-23 02:37:11 -07:00
Andrew Kelley
00acf8a66d std.http.Server: remove source code from doc comments
Documentation comments are not an appropriate place to put code samples.
2024-02-23 02:37:11 -07:00
Andrew Kelley
50e2a5f673 std.http: remove 'done' flag
This is a state machine that already has a `state` field. No need to
additionally store "done" - it just makes things unnecessarily
complicated and buggy.
2024-02-23 02:37:11 -07:00
Andrew Kelley
06d0c58305 std.mem: take advantage of length-based slicing 2024-02-23 02:37:10 -07:00
Andrew Kelley
b47bd031ca std.http.Server: protect against zero-length chunks
companion commit to 919a3bae1c5f2024b09e127a15c752d9dc0aa9a6
2024-02-23 02:37:10 -07:00
Andrew Kelley
90bd4f226e std.http: remove the ability to heap-allocate headers
The buffer for HTTP headers is now always provided via a static buffer.
As a consequence, OutOfMemory is no longer a member of the read() error
set, and the API and implementation of Client and Server are simplified.

error.HttpHeadersExceededSizeLimit is renamed to
error.HttpHeadersOversize.
2024-02-23 02:37:10 -07:00
Andrew Kelley
f1cf300c8f std.http.Server: fix error set
It incorrectly had NotWriteable and MessageTooLong in it.
2024-02-23 02:37:10 -07:00
Andrew Kelley
f58c59f89f std.http.Server: don't emit Server HTTP header
Let the user add that if they wish to. It's not strictly necessary, and
arguably a harmful default.
2024-02-23 02:37:10 -07:00
Jakub Konka
f8989a9c69 ci: bump QEMU to 8.2.1 on x86_64-linux machines 2024-02-23 10:30:34 +01:00
Andrew Kelley
256c5934bf std.tar: remove abuse of inline fn
In general, any `inline fn` should document why it is using `inline`
because the rule of thumb is: don't use inline.
2024-02-23 01:16:44 -08:00
Jacob Young
7f3ade6dea Builder: fix x86_fp80 constants in bitcode 2024-02-23 09:15:58 +01:00
Jacob Young
800495afab Builder: fix minor llvm ir syntax errors 2024-02-23 07:51:38 +01:00
Jacob Young
6abb432598 Builder: implement opaque structs in bitcode 2024-02-23 07:51:38 +01:00
Jacob Young
43daed64fe Builder: change tuple metadata to not be inlined in llvm ir 2024-02-23 06:18:10 +01:00
Jacob Young
1d4a7e123c llvm: revert bad cleanup 2024-02-23 03:23:49 +01:00
Jacob Young
be4ad235a7 Builder: fix inconsequential llvm ir metadata syntax 2024-02-23 03:23:49 +01:00
Jacob Young
8d0f6605fe Builder: sync distinct bits with previous implementation 2024-02-23 03:23:49 +01:00
Igor Anić
30f15e3afe fix crash in tar found by fuzzing
Running fuzzing tar test with [zig std lib
fuzzing](https://github.com/squeek502/zig-std-lib-fuzzing) reached and
assert in tar implementation. Assert (in std lib) should not be
reachable by external input, so I'm fixing this to return error.
2024-02-22 18:20:05 -08:00
antlilja
dfde194287 LLVM Builder: Make some Metadata no longer be distinct 2024-02-23 03:12:54 +01:00
antlilja
0ba2185a42 LLVM Builder: Formatting 2024-02-23 03:12:35 +01:00
Jacob Young
c894df54f7 Builder: fix debug location of the first instruction in a block 2024-02-23 01:45:25 +01:00
Jacob Young
dbfa3238fe Builder: fix float constants in llvm ir 2024-02-22 23:51:53 +01:00
Andrew Kelley
8802ec583b
Merge pull request #19032 from ianic/add_buffered_tee
propose adding BufferedTee to the std.io
2024-02-22 14:02:17 -08:00
Jacob Young
e60d667111 Module: fix @embedFile of files containing zero bytes
If an adapted string key with embedded nulls was put in a hash map with
`std.hash_map.StringIndexAdapter`, then an incorrect hash would be
entered for that entry such that it is possible that when looking for
the exact key that matches the prefix of the original key up to the
first null would sometimes match this entry due to hash collisions and
sometimes not if performed later after a grow + rehash, causing the same
key to exist with two different indices breaking every string equality
comparison ever, for example claiming that a container type doesn't
contain a field because the field name string in the struct and the
string representing the identifier to lookup might be equal strings but
have different string indices.  This could maybe be fixed by changing
`std.hash_map.StringIndexAdapter.hash` to only hash up to the first
null, therefore ensuring that the entry's hash is correct and that all
future lookups will be consistent, but I don't trust anything so instead
I assert that there are no embedded nulls.
2024-02-22 12:33:53 -08:00
Jae B
241e100827 update root.os.system override to require "system" field, this allows easier overriding of os.heap.page_allocator 2024-02-22 21:33:58 +02:00
Jacob Young
83e66d301e Builder: fix bitcode strtab 2024-02-22 19:50:41 +01:00
antlilja
2ab982eb13 Revert build.zig to old 7GB value 2024-02-22 19:41:53 +01:00
Jacob Young
69a6f31596 Builder: fix llvm ir value names
Hello world now verifies when not stripped.
2024-02-22 19:10:52 +01:00
Igor Anić
a5326c5ef8 return few previous fixes
Review: https://github.com/ziglang/zig/pull/19032#pullrequestreview-1896251841
2024-02-22 17:20:41 +01:00
antlilja
6cc51d3c33 LLVM: Set new debug location after inlining 2024-02-22 16:07:25 +01:00
antlilja
de536e8473 LLVM Builder: Emit metadata kinds and function metadata attachments 2024-02-22 15:29:28 +01:00
antlilja
92eec8dfec LLVM Builder: Emit type for debug subprogram 2024-02-22 15:24:22 +01:00
Igor Anić
d00faa2407 use BufferedTee in Fetch/git.zig 2024-02-22 15:18:03 +01:00
Igor Anić
eb67fab2d9 refactor according to Ian's review
https://github.com/ziglang/zig/pull/19032#pullrequestreview-1894702793
2024-02-22 12:29:21 +01:00
Jacob Young
4b215e3a11 Builder: support printing metadata in llvm ir 2024-02-22 08:54:35 +01:00
Andre Weissflog
dd1fc1cb8c std.os.emscripten: fix regression caused by code cleanup in std.os.wasi (Closes #19019) 2024-02-21 17:09:29 -08:00
antlilja
a907353ca4 LLVM Builder: Fix on 32-bit systems 2024-02-22 00:39:56 +01:00
Jakub Konka
a92e6146da elf+riscv: return an error for unimplemented HI20 forward lookup 2024-02-21 23:49:22 +01:00
Jakub Konka
6236f5b810 link+riscv: simplify bitSlice helper 2024-02-21 23:40:44 +01:00
Jakub Konka
2ad2e2f6f5 link+riscv: use riscv64/bits.zig to implement write helpers 2024-02-21 23:34:05 +01:00
antlilja
53f6071486 LLVM Builder: Emit debug vector types with DIVector flag 2024-02-21 23:33:25 +01:00
antlilja
5e9d0da43b LLVM Builder: Correctly emit debug subranges
The bitcode abbrev was missing the subrange code
2024-02-21 23:32:21 +01:00
Jakub Konka
ddb33baa11 test/link/elf: test static linking C riscv64-musl 2024-02-21 23:08:29 +01:00
Jakub Konka
720dd80007 elf+riscv: implement enough to get basic hello world in C working 2024-02-21 23:04:43 +01:00
Jakub Konka
ca6f41ee30 elf+riscv: skip parsing .riscv.attributes section for now 2024-02-21 22:50:55 +01:00
Jakub Konka
d19001abac elf: skip STT_NOTYPE only if SHN_UNDEF from symtab inclusion 2024-02-21 22:49:58 +01:00
Jakub Konka
9fd112804f link: commit missing files 2024-02-21 22:48:19 +01:00
Jakub Konka
8ba31ed39a elf: sort input relocs if targeting riscv64 2024-02-21 22:47:52 +01:00
Jakub Konka
55dadc3d85 test/link/elf: test static linking C aarch64-musl 2024-02-21 22:40:03 +01:00