Skip to content

Commit e9310e2

Browse files
Jake ChampionJakeChampion
Jake Champion
authored andcommitted
Add docmentation for the framing header features
1 parent 0df72fa commit e9310e2

File tree

4 files changed

+86
-0
lines changed

4 files changed

+86
-0
lines changed

documentation/docs/globals/Request/Request.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ new Request(input, options)
4141
- `backend` _**Fastly-specific**_
4242
- `cacheOverride` _**Fastly-specific**_
4343
- `cacheKey` _**Fastly-specific**_
44+
- `manualFramingHeaders`_: boolean_ _**optional**_ _**Fastly-specific**_
45+
- : The default value is `false`, which means that the framing headers are automatically created based on the message body.
46+
In "automatic" mode, a `Content-Length` is used when the size of the body can be determined before it is sent.
47+
Requests sent in streaming mode, where headers are sent immediately but the content of the body is streamed later, will receive a `Transfer-Encoding: chunked` to accommodate the dynamic generation of the body.
48+
In "manual" mode, any `Content-Length` or `Transfer-Encoding` headers will be honored.
49+
You must ensure that those headers have correct values permitted by the [HTTP/1.1 specification](https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.1).
50+
If the provided headers are not permitted by the specification, the headers will revert to "automatic" mode and a diagnostic message will be logged about what was wrong.
51+
If a `Content-Length` is permitted by the specification, but the value does not match the size of the actual body, the body will either be truncated (if it is too long), or the connection will be hung up early (if it is too short).
4452
- `fastly` _**Fastly-specific**_
4553
- `decompressGzip`_: boolean_ _**optional**_
4654
- Whether to automatically gzip decompress the Response or not.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
# Request.setManualFramingHeaders()
8+
9+
The **`setManualFramingHeaders()`** method of the `Request` interface controls how the framing headers should be determined.
10+
11+
By default the framing headers are set to "automatic" mode, which means they are created based on the body of the associated Request instance.
12+
In "automatic" mode, a `Content-Length` is used when the size of the body can be determined before it is sent.
13+
Requests sent in streaming mode, where headers are sent immediately but the content of the body is streamed later, will receive a `Transfer-Encoding: chunked` to accommodate the dynamic generation of the body.
14+
In "manual" mode, any `Content-Length` or `Transfer-Encoding` headers will be honored.
15+
You must ensure that those headers have correct values permitted by the [HTTP/1.1 specification](https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.1).
16+
If the provided headers are not permitted by the specification, the headers will revert to "automatic" mode and a diagnostic message will be logged about what was wrong.
17+
If a `Content-Length` is permitted by the specification, but the value does not match the size of the actual body, the body will either be truncated (if it is too long), or the connection will be hung up early (if it is too short).
18+
19+
## Syntax
20+
21+
## Syntax
22+
23+
```js
24+
setManualFramingHeaders(manual)
25+
```
26+
27+
### Parameters
28+
29+
- `manual` _: boolean_
30+
- : Whether or not to use "manual" mode for the framing headers.
31+
32+
### Return value
33+
34+
`undefined`.
35+

documentation/docs/globals/Response/Response.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,11 @@ new Response(body, options)
4545
- : Any headers you want to add to your response, contained
4646
within a [`Headers`](../../globals/Headers/Headers.mdx) object or object literal of
4747
[`String`](../../globals/String/String.mdx) key/value pairs.
48+
- `manualFramingHeaders`_: boolean_ _**optional**_ _**Fastly-specific**_
49+
- : The default value is `false`, which means that the framing headers are automatically created based on the message body.
50+
In "automatic" mode, a `Content-Length` is used when the size of the body can be determined before it is sent.
51+
Responses sent in streaming mode, where headers are sent immediately but the content of the body is streamed later, will receive a `Transfer-Encoding: chunked` to accommodate the dynamic generation of the body.
52+
In "manual" mode, any `Content-Length` or `Transfer-Encoding` headers will be honored.
53+
You must ensure that those headers have correct values permitted by the [HTTP/1.1 specification](https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.1).
54+
If the provided headers are not permitted by the specification, the headers will revert to "automatic" mode and a diagnostic message will be logged about what was wrong.
55+
If a `Content-Length` is permitted by the specification, but the value does not match the size of the actual body, the body will either be truncated (if it is too long), or the connection will be hung up early (if it is too short).
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
# Response.setManualFramingHeaders()
8+
9+
The **`setManualFramingHeaders()`** method of the `Response` interface controls how the framing headers should be determined.
10+
11+
By default the framing headers are set to "automatic" mode, which means they are created based on the body of the associated Response instance.
12+
In "automatic" mode, a `Content-Length` is used when the size of the body can be determined before it is sent.
13+
Responses sent in streaming mode, where headers are sent immediately but the content of the body is streamed later, will receive a `Transfer-Encoding: chunked` to accommodate the dynamic generation of the body.
14+
In "manual" mode, any `Content-Length` or `Transfer-Encoding` headers will be honored.
15+
You must ensure that those headers have correct values permitted by the [HTTP/1.1 specification](https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.1).
16+
If the provided headers are not permitted by the specification, the headers will revert to "automatic" mode and a diagnostic message will be logged about what was wrong.
17+
If a `Content-Length` is permitted by the specification, but the value does not match the size of the actual body, the body will either be truncated (if it is too long), or the connection will be hung up early (if it is too short).
18+
19+
## Syntax
20+
21+
## Syntax
22+
23+
```js
24+
setManualFramingHeaders(manual)
25+
```
26+
27+
### Parameters
28+
29+
- `manual` _: boolean_
30+
- : Whether or not to use "manual" mode for the framing headers.
31+
32+
### Return value
33+
34+
`undefined`.
35+

0 commit comments

Comments
 (0)