aboutsummaryrefslogtreecommitdiff
path: root/test/standalone/http.zig
AgeCommit message (Collapse)Author
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: 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-23update standalone http test file to new APIAndrew Kelley
2024-02-23std.net, std.http: simplifyAndrew Kelley
2024-02-23std.http.Client: remove bad decisions from fetch()Andrew Kelley
* "storage" is a better name than "strategy". * The most flexible memory-based storage API is appending to an ArrayList. * HTTP method should default to POST if there is a payload. * Avoid storing unnecessary data in the FetchResult * Avoid the need for a deinit() method in the FetchResult The decisions that this logic made about how to handle files is beyond repair: - fail to use sendfile() on a plain connection - redundant stat - does not handle arbitrary streams So, file-based response storage is no longer supported. Users should use the lower-level open() API which allows avoiding these pitfalls.
2024-02-23Revert "std.http: remove 'done' flag"Andrew Kelley
This reverts commit 42be972a72c86b32ad8403d082ab42763c6facec. Using a bit to distinguish between headers and trailers is fine. It was just named and documented poorly.
2024-02-23std: convert http trailers test to unit testAndrew Kelley
making it no longer dead code. it is currently failing.
2024-02-23std.http: remove Headers APIAndrew Kelley
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-23std.http: remove 'done' flagAndrew Kelley
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-01std: make options a struct instance instead of a namespaceVeikka Tuominen
2024-01-13std.http: add missing documentation and a few examplesNameless
2023-10-21std.http.Client: documentaion fixesNameless
2023-10-21std.http: rename start->send and request->open to be more inline with operationNameless
2023-10-21std.http.Server: improve documentation, do -> startNameless
Response.do was renamed to Response.start to mimic the naming scheme in http.Client
2023-10-21std.http.Client: add option to disable httpsNameless
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-21std.http.Client: store *Connection instead of a pool node, buffer writesNameless
2023-10-21std.http.Client: enhance proxy supportNameless
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-09-28std.http: introduce options to http client to allow for raw urisEmil Lerch
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-08-30std.http: allow for arbitrary http methodsNameless
2023-08-29std.http.Server: responses to HEAD not allowed to have a payloadNameless
2023-08-29std.http: handle expect:100-continue and continue responsesNameless
2023-08-29std.http: add Client.fetch and improve redirect logicNameless
2023-07-07std.http: fix leaked connections (#16341)Nameless
The early return in pool release was causing leaked connections. Closes #16282.
2023-06-17std.http: Fix segfault while redirectingMizuochi Keita
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-01std.http.Server: collapse BufferedConnection into ConnectionNameless
2023-05-06fix keepalive and large buffered writesNameless
2023-05-06std.http.Server: give Response access to their own allocatorNameless
* This makes it easier for threaded servers to use a different allocator for each request.
2023-05-06std.http.Server: use enum for reset state instead of boolNameless
2023-05-06std.http: add simple standalone http tests, add state check for http serverNameless