aws / aws/aws-sdk-cpp

Content-Type for files uploaded via S3 automatically set to application/xml

Offen
#1,840 2 Kommentare 4 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
documentation p3
Vorherrschende Sprache
C++
Sterne
2.2k
Forks
1.2k
Ø Merge
4 T. 11 Std.
Gemergte PRs (30 T.)
13

Beschreibung

### Describe the bug

When I upload a file to S3 (using a multipart upload request) the content-type of the file will be application/xml unless I specify otherwise. This seems incorrect as a content-type should be omitted if unknown or, at worst, default to application/octet-stream. Per RFC 7231 (3.1.1.5):

> A sender that generates a message containing a payload body SHOULD
> generate a Content-Type header field in that message unless the
> intended media type of the enclosed representation is unknown to the
> sender. If a Content-Type header field is not present, the recipient
> MAY either assume a media type of "application/octet-stream"
> ([RFC2046], Section 4.5.1) or examine the data to determine its type.

This ended up causing a bit of confusion here (https://github.com/apache/arrow/issues/11934). An S3 client was trying to be intelligent and inspect the XML data if the file was an XML file and this issue caused the client to inspect files it shouldn't.

### Expected behavior

If the content type of a file is not set then the file should either have no content-type or the content-type should be set to application/octet-stream.

### Current behavior

The file's content-type is set to application/xml

### Steps to Reproduce

Reproducible Gist: https://gist.github.com/westonpace/9c3a0baa48083f33aa4880c0cb6a602b

### Possible Solution

When the user does not specify a content-type either leave it unset or default to application/octet-stream

### AWS CPP SDK version used

1.8.185

### Compiler and Version used

GCC 9.3.0

### Operating System and version

Ubuntu 20.04.3

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, den multipart upload mit dem verknüpften Gist unter Verwendung von AWS SDK for C++ 1.8.185 zu reproduzieren, und verfolge dann die Verarbeitung der S3-multipart-upload-Anfrage, um herauszufinden, wo application/xml zugewiesen wird, wenn kein content type angegeben ist. Als erledigt gilt die Aufgabe, wenn ein nicht angegebener content type weggelassen oder als application/octet-stream gesendet wird und das Verhalten anhand der Reproduktion verifiziert wurde.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
aws, cpp
Bereich
cloud
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.