How to prevent Scrapy from automatically capitalizing the key of header

question

when developing a crawler with scrapy, grab the package with fiddler and find that scrapy will automatically capitalize the key of the requested header, such as accept-encoding into Accept-Encoding , and accept into Accept . The problem is that I don"t want to convert uppercase for some header due to validation problems.

methods that have been tried

I tried to change key.title () in the normkey method in scrapy/http/headers.py to key.lower ()

.
class Headers(CaselessDict):
    ...
    def normkey(self, key):
        """Normalize key to bytes"""
        return self._tobytes(key.title())  -sharp  key.lower()

seems to work, but in the end, what you see in fiddler is capitalized and verification fails

in addition, if you use requests to send requests, this will not happen. Packet grabbing is normal
, so you can basically rule out software and other environmental problems

.

I would like to ask you, in which step does scrapy convert the key of header into the capitalized

of the word?
Mar.09,2022

write header with no uppercase initials on top of the spider class in the spider file

from twisted.web.http_headers import Headers as TwistedHeaders

TwistedHeaders._caseMappings.update({
    b'uuid': b'uuid',
    b'content-type': b'content-type',
})

has the problem been solved? It still doesn't work when I set it up through TwistedHeaders._caseMappings.update. This code is run in the start_request () method, and the first letter of key in headers is still capitalized.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35062-2bf58.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35062-2bf58.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?