Do not supply a default content type.
Nessuno ha ancora preso questa issue.
- Lingua principale
- Ruby
- Stelle
- 148
- Fork
- 95
- Merge medio
- 10h 54m
- PR unite (30g)
- 4
Descrizione
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
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con supply_default_content_type in lib/net/http/generic_request.rb intorno alla riga 263, quindi confronta il suo comportamento con le indicazioni della RFC 7231 citate nell’issue. La modifica è completa quando Net::HTTP non fornisce più un Content-Type presunto per un body sconosciuto, incluso il caso d’uso in stile AWS descritto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- ruby
- Ambito
- networking
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100