今天发现 urllib2.Request.add_header() 加的头自动变成只有开头字母大写。

软件和网站开发以及相关技术探讨
回复
fuhuizn
帖子: 948
注册时间: 2006-01-06 22:55
系统: ubuntu
联系:

今天发现 urllib2.Request.add_header() 加的头自动变成只有开头字母大写。

#1

帖子 fuhuizn » 2008-11-25 16:12

很死板,没法关闭这个功能。
头像
xhy
帖子: 3916
注册时间: 2005-12-28 1:16
系统: Ubuntu 12.10 X64
来自: 火星

Re: 今天发现 urllib2.Request.add_header() 加的头自动变成只有开头字母大写。

#2

帖子 xhy » 2008-11-25 19:09

代码: 全选

 The request-header fields allow the client to pass additional information about the request, and about the client itself, to the server. These fields act as request modifiers, with semantics equivalent to the parameters on a programming language method invocation.

       request-header = Accept                   ; Section 14.1
                      | Accept-Charset           ; Section 14.2
                      | Accept-Encoding          ; Section 14.3
                      | Accept-Language          ; Section 14.4
                      | Authorization            ; Section 14.8
                      | Expect                   ; Section 14.20
                      | From                     ; Section 14.22
                      | Host                     ; Section 14.23
                      | If-Match                 ; Section 14.24
                      | If-Modified-Since        ; Section 14.25
                      | If-None-Match            ; Section 14.26
                      | If-Range                 ; Section 14.27
                      | If-Unmodified-Since      ; Section 14.28
                      | Max-Forwards             ; Section 14.31
                      | Proxy-Authorization      ; Section 14.34
                      | Range                    ; Section 14.35
                      | Referer                  ; Section 14.36
                      | TE                       ; Section 14.39
                      | User-Agent               ; Section 14.43

Request-header field names can be extended reliably only in combination with a change in the protocol version. However, new or experimental header fields MAY be given the semantics of request- header fields if all parties in the communication recognize them to be request-header fields. Unrecognized header fields are treated as entity-header fields. 
rfc协议已经这么规定了,不符合这些写法的header都是错误的header。自动转换是为了纠正你的错误。对于特殊需求,可以自己写socket
目前负债150多万
回复