NSURLRequest cannot handle HTTP body when method is not POST?

前端 未结 3 1604
醉话见心
醉话见心 2020-12-17 17:01

Whenever I set a body on a mutable request with the method set to anything other than POST, the body is not included in the request and I get a kCFErrorDomainCFNetwork error

3条回答
  •  难免孤独
    2020-12-17 17:40

    Are you remembering to set the Content-Length/Transfer-Encoding and Content-Type headers? I don't think that Content-Length is put in automatically for you, which means the server is going to assume it's 0.

    More info: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

提交回复
热议问题