AliSoftware / AliSoftware/OHHTTPStubs

Can't get HTTP headers from stubbed request

Đang mở
#274 5 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Objective-C
Star
5.1k
Fork
597
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### New Issue Checklist

- [x] I have tried with the latest version of OHHTTPStubs
- [x] I have read the [README](https://github.com/AliSoftware/OHHTTPStubs/blob/master/README.md)
- [x] I have read the [Using the right Swift Version of `OHHTTPStubs` for your project](https://github.com/AliSoftware/OHHTTPStubs#using-the-right-swift-version-of-ohhttpstubs-for-your-project) section
- [x] I have searched in the [existing issues](https://github.com/AliSoftware/OHHTTPStubs/issues?utf8=✓&q=is%3Aissue)
- [x] I have read [the OHHTTPStubs wiki](https://github.com/AliSoftware/OHHTTPStubs/wiki) to see if there wasn't a detailed page talking about my issue

### Environment

- version of OHHTTPStubs: 6.1.0
- integration method you are using:
* [x] Cocoapods
* [ ] Carthage
* [ ] submodule
* [ ] other
- version of the tool you use: 1.4.0

### Issue Description

I always get request.allHTTPHeaderFields == nil. At least there should be an auto-generated user-agent header.

Here is my stub code with redirection to the same url with substituted headers to set my custom cookie. request.allHTTPHeaderFields == nil in both cases: before and after redirection.

```
[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest * _Nonnull request) {
return YES;
} withStubResponse:^OHHTTPStubsResponse * _Nonnull(NSURLRequest * _Nonnull request) {
//allHTTPHeaderFields is always nil
NSDictionary *allHTTPHeaderFields = request.allHTTPHeaderFields;
return [OHHTTPStubsResponse responseWithData:[NSData data]
statusCode:302
headers:@{@"Location" : downloadURL,
@"Set-Cookie" : @"cookie_name=value"
}];
}];
```

Network request code:

```
AFHTTPSessionManager *sessionManager = [AFHTTPSessionManager manager];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
//.....
NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:nil
completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) {
//....
}];
[downloadTask resume];
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.