Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocktail headers not parsed correctly? #170

Closed
Ashton-W opened this issue May 3, 2016 · 3 comments
Closed

Mocktail headers not parsed correctly? #170

Ashton-W opened this issue May 3, 2016 · 3 comments

Comments

@Ashton-W
Copy link
Collaborator

Ashton-W commented May 3, 2016

Firstly, thanks so much for OHHTTPStubs.

I'm running into this error with loading stubs from Mocktail files:
Request failed: unacceptable content-type: content-type: application/json

From reading the code and this test project it looks like Line 4 of Mocktail files is always interpreted as the value of the Content-Type header.

The documentation and reference implementation here https://github.com/puls/objc-mocktail/blob/master/Mocktail/Mocktail.m#L247 (which was transferred from the square github account to puls) shows that Line 4 and every following line until a blank line are interpreted header keys and values.

Fixing this might be considered an breaking change. But since the Mocktail format is far from standardized we could accept both formats by checking for a colon : on Line 4.


PS: Is HTTPMessage similar to Mocktail? I tried to find some documentation of it on the web but kept coming up with Java and Ruby documention of classes with that name 😆.

@AliSoftware
Copy link
Owner

AliSoftware commented May 3, 2016

Interesting. Maybe @JinlianWang, who is the one who implemented the Mocktail support in #108, has more information?

But indeed I'd agree on fixing that and support both formats by checking the presence of a : on line 4!
(PR welcome, btw 😉 )


As for HTTPMessage that's the format generated by curl -is; so it's a little bit different than Mocktail, but very similar anyway, containing headers then body in a text format. Not sure if it's documented/used widely outside of curl though.

@Ashton-W
Copy link
Collaborator Author

Ashton-W commented May 4, 2016

I might just be misunderstanding Mocktail. This https://github.com/kif-framework/AMYServer framework has th content type on line 4 then header key values on the following lines...

@JinlianWang
Copy link
Contributor

Was not aware of the difference. I guess it is better to support both formats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants