-1

I 'm creating URLRequest with "Authorization" header and it works fine with most of app users but recently I faced that some users cannot make the requst.

apple says that "Certain header fields are reserved (see Reserved HTTP Headers). Do not use this property to set such headers." and i found that i used some of these headers

my question is how to set such headers?

MAHMOUD OMARA
  • 85
  • 1
  • 6

1 Answers1

-2

Read the docs

Reserved HTTP Headers The URL Loading System handles various aspects of the HTTP protocol for you (HTTP 1.1 persistent connections, proxies, authentication, and so on). As part of this support, the URL Loading System takes responsibility for certain HTTP headers:

Content-Length

Authorization

Connection

Host

Proxy-Authenticate

Proxy-Authorization

WWW-Authenticate

If you set a value for one of these reserved headers, the system may ignore the value you set, or overwrite it with its own value, or simply not send it. Moreover, the exact behavior may change over time. To avoid confusing problems like this, do not set these headers directly.

This means you shouldn't manually set these headers. If you REALLY have to then that means there is something wrong with YOUR API.

https://developer.apple.com/documentation/foundation/nsurlrequest#1776617

Zun
  • 1,553
  • 3
  • 15
  • 26