Do not supply a default content type.
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Ruby
- Sterne
- 148
- Forks
- 95
- Ø Merge
- 10 Std. 54 Min.
- Gemergte PRs (30 T.)
- 4
Beschreibung
Hello.
I would like to know if you would welcome a change to remove suppy_default_content_type.
Checking RFC for Content-Type: https://datatracker.ietf.org/doc/html/rfc7231#section-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.
Based on the RFC, I think Net::HTTP behavior is incorrect - assuming a default content type is not correct because the media type is not known unless Net::HTTP reads/inspects the body. The receiver may assume octet-stream unless provided.
This has caused issues with AWS services, where content type may be a modeled API parameter in REST services, like with S3 where you can specify the content type of an object. Currently we work around this with a patch:
Thread.current[:net_http_skip_default_content_type] = true
def self.apply!
Net::HTTPGenericRequest.prepend(PatchDefaultContentType)
end
module PatchDefaultContentType
def supply_default_content_type
return if Thread.current[:net_http_skip_default_content_type]
super
end
end
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit supply_default_content_type in lib/net/http/generic_request.rb bei etwa Zeile 263 und vergleiche anschließend sein Verhalten mit den im Issue zitierten RFC 7231-Richtlinien. Die Änderung ist abgeschlossen, wenn Net::HTTP für einen unbekannten Body keinen angenommenen Content-Type mehr bereitstellt, einschließlich des beschriebenen AWS-artigen Anwendungsfalls.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- ruby
- Bereich
- networking
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100