mirror of
https://github.com/actix/actix-website
synced 2024-11-23 16:31:08 +01:00
parent
7d15d13901
commit
ac29615601
@ -94,7 +94,7 @@ Actix Web keeps connections open to wait for subsequent requests.
|
||||
|
||||
<CodeBlock example="server" file="keep_alive.rs" section="keep-alive" />
|
||||
|
||||
If the first option above is selected, then keep-alive is enabled for HTTP/1.1 requests if the response does not explicitly disallow it by, for example, setting the [connection type][httpconnectiontype] to `Close` or `Upgrade`. Force closing a connection can be done with [the `force_close()` method on `HttpResponseBuilder`](https://docs.rs/actix-web/4/actix_web/dev/struct.HttpResponseBuilder.html#method.force_close)
|
||||
If the first option above is selected, then keep-alive is enabled for HTTP/1.1 requests if the response does not explicitly disallow it by, for example, setting the [connection type][httpconnectiontype] to `Close` or `Upgrade`. Force closing a connection can be done with [the `force_close()` method on `HttpResponseBuilder`](https://docs.rs/actix-web/4/actix_web/struct.HttpResponseBuilder.html#method.force_close)
|
||||
|
||||
> Keep-alive is **off** for HTTP/1.0 and is **on** for HTTP/1.1 and HTTP/2.0.
|
||||
<CodeBlock example="server" file="keep_alive_tp.rs" section="example" />
|
||||
|
@ -32,11 +32,11 @@ If you need more complex application configuration, testing should be very simil
|
||||
|
||||
## Stream response tests
|
||||
|
||||
If you need to test stream generation, it would be enough to call `take_body()` and convert a resulting [_ResponseBody_][responsebody] into a future and execute it, for example when testing [_Server Sent Events_][serversentevents].
|
||||
If you need to test stream generation, it would be enough to call [`into_parts()`][resintoparts] and convert the resulting body into a future and execute it, for example when testing [_Server Sent Events_][serversentevents].
|
||||
|
||||
<CodeBlock example="testing" file="stream_response.rs" section="stream-response" />
|
||||
|
||||
[serversentevents]: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events
|
||||
[responsebody]: https://docs.rs/actix-web/4/actix_web/body/enum.ResponseBody.html
|
||||
[resintoparts]: https://docs.rs/actix-web/4/actix_web/struct.HttpResponse.html#method.into_parts
|
||||
[actixdocs]: https://docs.rs/actix-web/4/actix_web/test/index.html
|
||||
[testrequest]: https://docs.rs/actix-web/4/actix_web/test/struct.TestRequest.html
|
||||
|
@ -74,7 +74,7 @@ A _variable part_ (replacement marker) is specified in the form _{identifier}_,
|
||||
|
||||
A replacement marker in a pattern matches the regular expression `[^{}/]+`.
|
||||
|
||||
A match_info is the `Params` object representing the dynamic parts extracted from a _URL_ based on the routing pattern. It is available as _request.match_info_. For example, the following pattern defines one literal segment (foo) and two replacement markers (baz, and bar):
|
||||
A match*info is the `Params` object representing the dynamic parts extracted from a \_URL* based on the routing pattern. It is available as _request.match_info_. For example, the following pattern defines one literal segment (foo) and two replacement markers (baz, and bar):
|
||||
|
||||
```
|
||||
foo/{baz}/{bar}
|
||||
@ -206,7 +206,7 @@ Use the [_HttpRequest.url_for()_][urlfor] method to generate URLs based on resou
|
||||
|
||||
<CodeBlock example="url-dispatch" file="urls.rs" section="url" />
|
||||
|
||||
This would return something like the string *http://example.com/test/1/2/3* (at least if the current protocol and hostname implied http://example.com). `url_for()` method returns [_Url object_][urlobj] so you can modify this url (add query parameters, anchor, etc). `url_for()` could be called only for _named_ resources otherwise error get returned.
|
||||
This would return something like the string `http://example.com/test/1/2/3` (at least if the current protocol and hostname implied http://example.com). `url_for()` method returns [_Url object_][urlobj] so you can modify this url (add query parameters, anchor, etc). `url_for()` could be called only for _named_ resources otherwise error get returned.
|
||||
|
||||
## External resources
|
||||
|
||||
|
@ -9,5 +9,4 @@ Want to talk to others about questions? The Actix Web [Discord server](https://d
|
||||
|
||||
If you think you found a bug it's best to file an issue directly on the repo. [actix/actix-web](https://github.com/actix/actix-web) for the web framework. [actix/actix](https://github.com/actix/actix) for issues with the actor framework
|
||||
|
||||
We're a welcoming community so don't be afraid to engage. Interactions are
|
||||
[governed by our code of conduct](community/coc).
|
||||
We're a welcoming community so don't be afraid to engage. Interactions are [governed by our code of conduct](/community/coc).
|
||||
|
Loading…
Reference in New Issue
Block a user