aboutsummaryrefslogtreecommitdiff
path: root/lib/std/http/test.zig
AgeCommit message (Collapse)Author
2025-11-01Revert "std.http: disable failing test on 32-bit arm"Jacob Young
This reverts commit 16185f66f1e500d61d43550e7c847a36ad1032df. Which was fixed by d000574380baba7b63fdcde713b51f8318509474. Closes #25762
2025-10-29std.http: disable failing test on 32-bit armAndrew Kelley
tracked by https://github.com/ziglang/zig/issues/25762
2025-10-29WIP: hack away at std.Io return flightAndrew Kelley
2025-10-29WIP: hack at std.Io on a planeAndrew Kelley
2025-10-06fix read of undefined in http testsxdBronch
2025-08-15std.compress.zstd.Decompress fixesAndrew Kelley
* std.Io.Reader: appendRemaining no longer supports alignment and has different rules about how exceeding limit. Fixed bug where it would return success instead of error.StreamTooLong like it was supposed to. * std.Io.Reader: simplify appendRemaining and appendRemainingUnlimited to be implemented based on std.Io.Writer.Allocating * std.Io.Writer: introduce unreachableRebase * std.Io.Writer: remove minimum_unused_capacity from Allocating. maybe that flexibility could have been handy, but let's see if anyone actually needs it. The field is redundant with the superlinear growth of ArrayList capacity. * std.Io.Writer: growingRebase also ensures total capacity on the preserve parameter, making it no longer necessary to do ensureTotalCapacity at the usage site of decompression streams. * std.compress.flate.Decompress: fix rebase not taking into account seek * std.compress.zstd.Decompress: split into "direct" and "indirect" usage patterns depending on whether a buffer is provided to init, matching how flate works. Remove some overzealous asserts that prevented buffer expansion from within rebase implementation. * std.zig: fix readSourceFileToAlloc returning an overaligned slice which was difficult to free correctly. fixes #24608
2025-08-13std.io.Writer.Allocating: rename getWritten() to written()Isaac Freund
This "get" is useless noise and was copied from FixedBufferWriter. Since this API has not yet landed in a release, now is a good time to make the breaking change to fix this.
2025-08-11std.ArrayList: make unmanaged the defaultAndrew Kelley
2025-08-07std.http.Client: fix fetching by adding a bufferAndrew Kelley
2025-08-07std.http: remove custom method supportAndrew Kelley
let's see if anybody notices it missing
2025-08-07std.http.Server: add safety for invalidated Head stringsAndrew Kelley
and fix bad unit test API usage that it finds
2025-08-07std.Io.Reader: fix appendRemainingUnlimitedAndrew Kelley
Now it avoids mutating `r` unnecessarily, allowing the `ending` Reader to work.
2025-08-07http fixesAndrew Kelley
2025-08-07std.http: rework for new std.Io APIAndrew Kelley
2025-07-14std.net: update to new I/O APIAndrew Kelley
2025-07-07std.fmt: breaking API changesAndrew Kelley
added adapter to AnyWriter and GenericWriter to help bridge the gap between old and new API make std.testing.expectFmt work at compile-time std.fmt no longer has a dependency on std.unicode. Formatted printing was never properly unicode-aware. Now it no longer pretends to be. Breakage/deprecations: * std.fs.File.reader -> std.fs.File.deprecatedReader * std.fs.File.writer -> std.fs.File.deprecatedWriter * std.io.GenericReader -> std.io.Reader * std.io.GenericWriter -> std.io.Writer * std.io.AnyReader -> std.io.Reader * std.io.AnyWriter -> std.io.Writer * std.fmt.format -> std.fmt.deprecatedFormat * std.fmt.fmtSliceEscapeLower -> std.ascii.hexEscape * std.fmt.fmtSliceEscapeUpper -> std.ascii.hexEscape * std.fmt.fmtSliceHexLower -> {x} * std.fmt.fmtSliceHexUpper -> {X} * std.fmt.fmtIntSizeDec -> {B} * std.fmt.fmtIntSizeBin -> {Bi} * std.fmt.fmtDuration -> {D} * std.fmt.fmtDurationSigned -> {D} * {} -> {f} when there is a format method * format method signature - anytype -> *std.io.Writer - inferred error set -> error{WriteFailed} - options -> (deleted) * std.fmt.Formatted - now takes context type explicitly - no fmt string
2024-09-19disable failing testAndrew Kelley
tracked by #21457
2024-04-10Uri: propagate per-component encodingJacob Young
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-02-28std.http: add tests against regressions for conforming fieldsNameless
2024-02-26http: fix fetching a github releaseJacob Young
* 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-26std.http.Server: fix use case of streaming both reading and writingAndrew Kelley
2024-02-26std.http.Client: fix UAF when handling redirectsAndrew Kelley
closes #19071
2024-02-25Merge pull request #19077 from Techatrix/http-header-parseAndrew Kelley
http: check for empty header name instead of value
2024-02-25http: handle header fields with empty valueTechatrix
2024-02-24std.http tests: wait for server responseAndrew Kelley
This avoids a race that can make the unit test fail
2024-02-23std.http.Server: expose arbitrary HTTP headersAndrew Kelley
Ultimate flexibility, just be sure to destroy the correct amount of information when looking at them.
2024-02-23std.http: disable the test that was never passing on windowsAndrew Kelley
We didn't know it wasn't passing before because it wasn't actually being run.
2024-02-23wasi: don't try to test httpAndrew Kelley
wasi does not support networking
2024-02-23std.http: migrate remaining test/standalone/http.zig to std libAndrew Kelley
These tests were not being actually run. Now they are run along with testing the standard library.
2024-02-23std.http.Server: implement respondStreaming with unknown lenAndrew Kelley
no content-length header no transfer-encoding header
2024-02-23std.http: refactor unit testsAndrew Kelley
avoid a little bit of boilerplate
2024-02-23std.http.Server: handle expect: 100-continue requestsAndrew Kelley
The API automatically handles these requests as expected. After receiveHead(), the server has a chance to notice the expectation and do something about it. If it does not, then the Server implementation will handle it by sending the continuation header when the read stream is created. Both respond() and respondStreaming() send the continuation header as part of discarding the request body, only if the read stream has not already been created.
2024-02-23std.http.Server.Request.Respond: support all transfer encodingsAndrew Kelley
Before I mistakenly thought that missing content-length meant zero when it actually means to stream until the connection is closed. Now the respond() function accepts transfer_encoding which can be left as default (use content.len for content-length), set to none which makes it omit the content-length, or chunked, which makes it format the response as a chunked transfer even though the server has the entire contents already buffered. The echo-content tests are moved from test/standalone/http.zig to the standard library where they are actually run.
2024-02-23std.http.Server: reimplement chunked uploadingAndrew Kelley
* Uncouple std.http.ChunkParser from protocol.zig * Fix receiveHead not passing leftover buffer through the header parser. * Fix content-length read streaming This implementation handles the final chunk length correctly rather than "hoping" that the buffer already contains \r\n.
2024-02-23std.http.Server: rework the API entirelyAndrew Kelley
Mainly, this removes the poorly named `wait`, `send`, `finish` functions, which all operated on the same "Response" object, which was actually being used as the request. Now, it looks like this: 1. std.net.Server.accept() gives you a std.net.Server.Connection 2. std.http.Server.init() with the connection 3. Server.receiveHead() gives you a Request 4. Request.reader() gives you a body reader 5. Request.respond() is a one-shot, or Request.respondStreaming() creates a Response 6. Response.writer() gives you a body writer 7. Response.end() finishes the response; Response.endChunked() allows passing response trailers. In other words, the type system now guides the API user down the correct path. receiveHead allows extra bytes to be read into the read buffer, and then will reuse those bytes for the body or the next request upon connection reuse. respond(), the one-shot function, will send the entire response in one syscall. Streaming response bodies no longer wastefully wraps every call to write with a chunk header and trailer; instead it only sends the HTTP chunk wrapper when flushing. This means the user can still control when it happens but it also does not add unnecessary chunks. Empirically, in my example project that uses this API, the usage code is significantly less noisy, it has less error handling while handling errors more correctly, it's more obvious what is happening, and it is syscall-optimal. Additionally: * Uncouple std.http.HeadParser from protocol.zig * Delete std.Server.Connection; use std.net.Server.Connection instead. - The API user supplies the read buffer when initializing the http.Server, and it is used for the HTTP head as well as a buffer for reading the body into. * Replace and document the State enum. No longer is there both "start" and "first".
2024-02-23std.net, std.http: simplifyAndrew Kelley
2024-02-23std.http: skip tests on wasi and single-threadedAndrew Kelley
WASI does not support networking, and these tests require threads.
2024-02-23std.http: parser fixesAndrew Kelley
* add API for iterating over custom HTTP headers * remove `trailing` flag from std.http.Client.parse. Instead, simply don't call parse() for trailers. * fix the logic inside that parse() function. it was using wrong std.mem functions, ignoring malformed data, and returned errors on dead branches. * simplify logic inside wait() * fix HeadersParser not dropping the 2 read bytes of \r\n after a chunked transfer * move the trailers test to be a std lib unit test and make it pass
2024-02-23std: convert http trailers test to unit testAndrew Kelley
making it no longer dead code. it is currently failing.
2023-05-06std.http: add simple standalone http tests, add state check for http serverNameless
2023-04-26std.http: do -> wait, fix redirectsNameless
2023-04-21create std.http.Server.Response.deinit to handle keepalive connectionsRyo Ota
2023-04-21move the HTTP test to lib/std/http/test.zigRyo Ota