gpt4 book ai didi

ios - NSURLSessionConfiguration HTTPAdditionalHeaders 未设置

转载 作者:可可西里 更新时间:2023-11-01 03:51:57 25 4
gpt4 key购买 nike

授权 header 在 NSURLSessionConfiguration 中设置,但是它没有附加到 NSURLSessionDataTask。这是 Foundation framework 中的错误吗?

NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
[configuration setHTTPAdditionalHeaders:@{@"Authorization":@"123"}];

// Initialize session with NSURLSessionConfiguration
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
NSURLSessionDataTask *sessionTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
}];

[sessionTask resume];

最佳答案

在 NSURLSessionConfiguration document ,

An NSURLSession object is designed to handle various aspects of the HTTP protocol for you. As a result, you should not modify the following headers:

Authorization

Connection

Host

WWW-Authenticate

关于ios - NSURLSessionConfiguration HTTPAdditionalHeaders 未设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24751768/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com