AliSoftware / AliSoftware/OHHTTPStubs

Saved Responses for 204 No Content Returned as 200s

Đang mở
#296 0 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ả

- [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: CocoaPods 1.6, Xcode Version 10.1 (10B61)

### Issue Description

In my tests, I have some stubbed network responses for when the server returns a 204 No Content response. I have them saved as `.response` files in a test bundle, just like any other response. When they are returned by OHHTTPStubs, however, they’re returned with a 200 status code, with the contents of the file as the data. This is due to the fact that `CFHTTPMessageIsHeaderComplete()` returns `false` with the following response:

```
HTTP/1.1 204 No Content
Date: Sat, 19 Jan 2019 15:13:01 GMT
Connection: close
```

This parsing happens here: https://github.com/AliSoftware/OHHTTPStubs/blob/826a9217fcd468220d154ed0075cbc1a20d0c5c9/OHHTTPStubs/Sources/HTTPMessage/OHHTTPStubsResponse%2BHTTPMessage.m#L48

I can manually create these responses for now, but I’m wondering if we should get the status code from the response before calling `CFHTTPMessageIsHeaderComplete()` to check for 204 status codes, for which we’d return `nil` for the data.

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.