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

HTTP doesn't detect JSON body #3168

Closed
RunDevelopment opened this issue Oct 25, 2021 · 2 comments · Fixed by #3169
Closed

HTTP doesn't detect JSON body #3168

RunDevelopment opened this issue Oct 25, 2021 · 2 comments · Fixed by #3169

Comments

@RunDevelopment
Copy link
Member

Information

  • Language: HTTP+JSON
  • Plugins: none

Description
HTTP fails to detect the JSON body even though the Content-type is set.

As reported by @drrk here.

Code snippet

Test page

The code being highlighted incorrectly.
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 523
Content-Type: application/json
Server: gunicorn/19.9.0
X-Kong-Proxy-Latency: 1
X-Kong-Upstream-Latency: 1
{
    "args": {},
    "data": "",
    "files": {},
    "form": {},
    "headers": {
        "Accept": "*/*",
        "Accept-Encoding": "gzip, deflate",
        "Connection": "close",
        "Host": "httpbin.org",
        "User-Agent": "HTTPie/1.0.2",
        "X-Forwarded-Host": "example.com"
    },
    "json": null,
    "method": "GET",
    "origin": "172.19.0.1, 52.201.239.166",
    "url": "http://example.com/anything"
}
@RunDevelopment
Copy link
Member Author

Found the problem @drrk.

Your HTTP message isn't valid. HTTP requires an empty line between headers and the body.

image

However, I wonder whether we should relax Prism a little here to these almost-valid HTTP messages. What do you think @drrk?

@drrk
Copy link

drrk commented Oct 25, 2021

Oh Thanks! I can fix my examples with no problem. However, I am always in favour of following Jon Postel with "Be liberal in what you accept, and conservative in what you send."

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

Successfully merging a pull request may close this issue.

2 participants