Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally decode generic HTTP payloads #26

Merged
merged 2 commits into from
Nov 12, 2021

Conversation

jpneverwas
Copy link
Contributor

Hi,

Some clients refuse to send payloads that don't match the Content-Type. That is, trying to send %BOLD hw or \x02 hw (unescaped) would be disallowed for Content-Type: application/x-www-form-urlencoded unless first encoded. As many likely know (and perhaps prefer), curl's -d|--data option sends this very header despite not doing any encoding. And irccat, it seems, was designed to expect this combination, so it doesn't perform any decoding.

However, it might be nice to allow problematic clients to specify a config option (I've called it http.listeners.generic.strict), to get the following behavior:

Mismatch

$ echo "%BOLDhw" | curl -d @- http://localhost/send
400 Bad Request

urlencoded

$ echo "%BOLDhw" | curl --data-urlencode  @- http://localhost/send
200 OK

urlencoded non-printable char

$ printf "\x02hw" | curl --data-urlencode  @- http://localhost/send
200 OK

octetstream

$ echo "%BOLDhw" | curl --data-binary @- \
    -H 'Content-Type: application/octet-stream' http://localhost/send
200 OK

multipart quoted-printable

$ echo '%BOLDhw' | curl -F 'foo=@-;encoder=quoted-printable' \
    http://localhost/send
200 OK

multipart 8bit

$ echo '%BOLDhw' | curl -F 'foo=@-;encoder=8bit' http://localhost/send
200 OK

multipart base64

$ echo '%BOLDhw' | curl -F 'foo=@-;encoder=base64' http://localhost/send
200 OK

IOW, when "strict" mode is active, popular encodings will work as expected.
Please see associated tests. Thanks.

examples/irccat.json Show resolved Hide resolved
@russss russss merged commit 2e430ea into irccloud:master Nov 12, 2021
@jpneverwas jpneverwas deleted the decode-generic branch November 13, 2021 02:08
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.

None yet

2 participants