Skip to content

Can't handle upload file when 'boundary‘’ parameter string without space or 'multipart/form-data' contains uppercase characters #112

@imfms

Description

@imfms

Reference: RFC9110 8.3.1. Media Type

The type and subtype tokens are case-insensitive.

For example, the following media types are equivalent in describing HTML text data encoded in the UTF-8 character encoding scheme, but the first is preferred for consistency (the "charset" parameter value is defined as being case-insensitive in [RFC2046], Section 4.1.2):

text/html;charset=utf-8
Text/HTML;Charset="utf-8"
text/html; charset="utf-8"
text/html;charset=UTF-8

SHELL2HTTP

shell2http -form POST:/file 'echo filepath: "$filepath_file"'

HTTP Request Message

POST /file HTTP/1.1
Host: localhost:8080
Content-Type: Multipart/form-data;boundary=----WebKitFormBoundaryItgqnQVmmCTe0kfJ
              ^ uppercase character
                                  ^ no space after ';'
Content-Length: 190

------WebKitFormBoundaryItgqnQVmmCTe0kfJ
Content-Disposition: form-data; name="file"; filename="hi"
Content-Type: application/octet-stream


------WebKitFormBoundaryItgqnQVmmCTe0kfJ--

CURL

curl -v 'http://localhost:8080/file' \
  -H 'Content-Type: Multipart/form-data;boundary=----WebKitFormBoundaryItgqnQVmmCTe0kfJ' \
  --data-raw $'------WebKitFormBoundaryItgqnQVmmCTe0kfJ\r\nContent-Disposition: form-data; name="file"; filename="hi"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n------WebKitFormBoundaryItgqnQVmmCTe0kfJ--\r\n'

Response

filepath: 
          ^ no file path

And I found the problem and will submit a PR later

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions