NSURLRequest setting the HTTP header

后端 未结 6 2076
名媛妹妹
名媛妹妹 2020-12-12 12:21

I need to set the HTTP header for a request. In the documentation for the NSURLRequest class I didn\'t find anything regarding the HTTP header. How can I set the HTTP header

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-12 13:16

    I know its late but may help others , For SWIFT 3.0

    let url = NSURL(string: "http://www.yourwebsite.com")
        let mutAbleRequest = NSMutableURLRequest(URL: url!)
        mutAbleRequest.setValue("YOUR_HEADER_VALUE", forHTTPHeaderField:"YOUR_HEADER_NAME")
        myWebView.loadRequest(mutAbleRequest)
    

提交回复
热议问题