Skip to content

Treat a whitespace-only header line as obs-fold - #348

Open
kou wants to merge 1 commit into
ruby:masterfrom
kou:whitespace-only-header
Open

kou wants to merge 1 commit into
ruby:masterfrom
kou:whitespace-only-header

Conversation

@kou

@kou kou commented Sep 18, 2026

Copy link
Copy Markdown
Member

The current implementation has a problem with the following case:

print("HTTP/1.1 200 OK\r\n")
print("Content-Length: 5\r\n")
print(" \t\r\n")
print("X-After: value\r\n")
print("\r\n")
print("hello")

The " \t\r\n" line should be processed as obs-fold in RFC 9112:

https://www.rfc-editor.org/rfc/rfc9112.html#section-5.2

obs-fold     = OWS CRLF RWS
             ; obsolete line folding

A user agent that receives an obs-fold in a response message that
is not within a "message/http" container MUST replace each received
obs-fold with one or more SP octets prior to interpreting the field
value.

But it's processed as the header part end:

Header:

HTTP/1.1 200 OK
Content-Length: 5

Body:

X-After: value

hello

It must be processed as the following (whitespace only obs-fold is ignored):

Header:

HTTP/1.1 200 OK
Content-Length: 5
X-After: value

Body:

hello

The current implementation has a problem with the following case:

```ruby
print("HTTP/1.1 200 OK\r\n")
print("Content-Length: 5\r\n")
print(" \t\r\n")
print("X-After: value\r\n")
print("\r\n")
print("hello")
```

The `" \t\r\n"` line should be processed as obs-fold in RFC 9112:

https://www.rfc-editor.org/rfc/rfc9112.html#section-5.2

>     obs-fold     = OWS CRLF RWS
>                  ; obsolete line folding
>
>     A user agent that receives an obs-fold in a response message that
>     is not within a "message/http" container MUST replace each received
>     obs-fold with one or more SP octets prior to interpreting the field
>     value.

But it's processed as the header part end:

Header:

```text
HTTP/1.1 200 OK
Content-Length: 5
```

Body:

```text
X-After: value

hello
```

It must be processed as the following (whitespace only obs-fold is
ignored):

Header:

```text
HTTP/1.1 200 OK
Content-Length: 5
X-After: value
```

Body:

```text
hello
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant