Skip to content

Support of \r\n characters in HTTP Headers as per HTTP 1.1 as per RFC 2616 sec 2.2 #61472

Open
@praveensri

Description

@praveensri

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The library breaks the scenario if HTTP headers uses the CRLF characters in the header. It is common in MIME transfer
"Content-Type": "multipart/report;\r\n\treport-type="disposition-notification";\r\n\tboundary="d9f60885-8cd2-4516-bc47-858c3c14d2aa""
The above content type is valid as per RFC
We addressed \t characters in the following PR but not other control characters US-ASCII (10 and 13)
#40633

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

No response

Anything else?

No response

Activity

added
area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
on Apr 13, 2025
MihaZupan

MihaZupan commented on Apr 14, 2025

@MihaZupan
Member

Notably such values in headers aren't interpreted as new lines, but as regular spaces, so a workaround of replacing these characters with spaces is valid.

As far as actually sending such characters over the wire, note that RFC 2616 was superseded by RFC 7230 (2014), which was in turn superseeded by RFC 9112.
Both call the feature "obsolete" and warn against using it:

A sender MUST NOT generate a message that includes line folding (i.e., that has any field line value that contains a match to the obs-fold rule) unless the message is intended for packaging within the "message/http" media type.

praveensri

praveensri commented on Apr 14, 2025

@praveensri
Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

      Participants

      @MihaZupan@praveensri

      Issue actions

        Support of \r\n characters in HTTP Headers as per HTTP 1.1 as per RFC 2616 sec 2.2 · Issue #61472 · dotnet/aspnetcore