postman-app-support icon indicating copy to clipboard operation
postman-app-support copied to clipboard

Parse error when no HTTP/ ... in the response message

Open SamuelH91 opened this issue 5 years ago • 44 comments

When server is sending response which doesn't have HTTP/1.1 .... in the beginning of the message Postman Desktop app gives an error "Parse Error: The server returned a malformed response". Below error message from console.

"POST http://192.168.225.1/ Error: Parse Error: Expected HTTP/ Request Headers Content-Type: application/json User-Agent: PostmanRuntime/7.26.5 Accept: / Host: 192.168.225.1 Request Body"

Response was otherwise only json. It is visible in Postman Chrome wihtout any errors.

SamuelH91 avatar Oct 19 '20 12:10 SamuelH91

Hey @SamuelH91

Are you able to provide us with an endpoint the full request that shows the issue as it's going to be difficult to reproduce the problem with that IP.

Which version of the app are you using?

DannyDainton avatar Oct 22 '20 14:10 DannyDainton

  • Newest desktop application on Windows.

Normally server should start it's response with something like this

HTTP/1.1 200 OK Date: < some date > Content-Type: application/json Content-Length: < actual size >

{"example":"data"}

This particular server skipped the beginning and went right to the json. Old Postman Chrome doesn't raise Parse Error like Postman Desktop version. Of course, I am able to see the response in Wireshark, but it isn't quite practical.

SamuelH91 avatar Oct 22 '20 15:10 SamuelH91

Is this an endpoint that you control or have control over?

Could you send the curl command for that request so that we can at least import it and see what it looks like.

DannyDainton avatar Oct 22 '20 16:10 DannyDainton

Not at the moment, but it isn't necessary at all. It easily replicated by sending the reply to any rest request (from Postman) from any server that doesn't include Http/1.1 .... + Headers to its response. The response ONLY includes json. Then you are able to see the Parse Error.

SamuelH91 avatar Oct 22 '20 16:10 SamuelH91

Can you give us an example of one that you have seen this happening with please?

Being able to replicate what you can see in front of you is vital to be able to investigate this more.

DannyDainton avatar Oct 22 '20 17:10 DannyDainton

I can probably code some extra simple server tomorrow if you are not able to replicate it before.

SamuelH91 avatar Oct 22 '20 17:10 SamuelH91

Can you share a screen shot of what you're seeing and the error that you can see in Postman.

DannyDainton avatar Oct 22 '20 17:10 DannyDainton

Here is a simple python test server:

simpleTestServer.zip

Run it (listens on 80 port) python simpleTestServer.py Make any rest requests from Postman to localhost: -> Every other message from server to any request from postman gives parse error. (Starting from error)

SamuelH91 avatar Oct 23 '20 11:10 SamuelH91

Example:

image

No response body visible when Parse Error

SamuelH91 avatar Oct 23 '20 11:10 SamuelH91

From old Postman chrome plugin (HTTP/1.1 ... not included in response) (No Parse Error): image

vs (HTTP/1.1 included in response)

image

SamuelH91 avatar Oct 23 '20 12:10 SamuelH91

I'm also having a very similar exception on postman when a HEAD request returns any content-length != 0 (which RFC says HEAD should return content-length same to what it would've been in if it was a GET)

I double checked with curl, same endpoint, same request, only difference is content-length being 0 and not.

Cediddi avatar Nov 02 '20 15:11 Cediddi

I'm getting the same error, simulating an empty request situation:

image Parse Error: The server returned a malformed response

image Error: Parse Error: Expected HTTP/

Here are the full payloads captured using Wireshark:

POST /wsRecarga.asmx/NotificarPagamentoProcessado HTTP/1.1
Content-Type: application/json
User-Agent: PostmanRuntime/7.26.10
Accept: */*
Cache-Control: no-cache
Postman-Token: daa04e18-8e75-430e-b039-1b29deeec4a9
Host: localhost:9080
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 0

HTTP/1.1 400 Bad Request
Cache-Control: private, max-age=0
Content-Length: 75
Content-Type: application/json
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?QzpcQ29kZVxiaXRidWNrZXRcdml2by13c3JlY2FyZ2Fcd3NSZWNhcmdhXHdzUmVjYXJnYS5hc214XE5vdGlmaWNhclBhZ2FtZW50b1Byb2Nlc3NhZG8=?=
X-Powered-By: ASP.NET
Date: Fri, 26 Feb 2021 18:55:56 GMT

{"resultCode":"err","failureReason":"P0013","message":"Empty request body"}{"d":null}

I think Postman should be able to parse the response or at least showing the raw response content, as it does for other situations.

The same request via curl works as expected.

natenho avatar Feb 26 '21 19:02 natenho

i have the same error, but in my case it's because the server is configured as http/2, and i think (?) postman doesn't support that? at least from searching around it looks like that might be the case. Anyway might not help but thought i'd add here as it's the exact same response that I see when trying to query a get on http/2 service

godspeed20 avatar Mar 10 '21 09:03 godspeed20

I've spend a hole day to figure out the issue but failed to resolved. It's not working for localhost, but for remote endpoint it works. Screenshot from 2021-03-24 21-42-50

below is the console output: Screenshot from 2021-03-24 21-43-05

al-amin-chayan avatar Mar 24 '21 15:03 al-amin-chayan

+1 having the same issue. is there any plan for fix this? seems like sometimes can't even use the Postman because of this

marufmax avatar Apr 20 '21 11:04 marufmax

In case this might be helpful for someone: I've been having this problem also on my local endpoint, i was sending HTTP status code 204 (No Content), i replaced it with 200 (OK) and everything worked fine I actually find this to be a strange issue, any explanations would be appreciated

Eyad-Bereh avatar Apr 28 '21 20:04 Eyad-Bereh

In my case, specify the status code fixed the problem. I had the same Parsing Error on Postman interface so I decided to do some tests using curl and I received the curl: (1) Received HTTP/0.9 when not allowed error. Then, forcing the proper status_code in the response header everything went smoothly.

enbis avatar May 15 '21 16:05 enbis

Also experiencing the same issue when the server returns a 204 empty response.

iforwms avatar May 27 '21 07:05 iforwms

I had the same problem today, but I resolved it setting the header Content-Length properly in my http response

lechediaz avatar Jun 10 '21 15:06 lechediaz

I solved it by setting the writeHead eg: response.writeHead(statusCode)
OR response.writeHead(statusCode, {'Content-Type': 'application/json'})

lydengit avatar Sep 23 '21 04:09 lydengit

Seems we are affected by same issue.

I am testing a local PHP/Apache website. it works fine for years we are developing, from command line and from API. Now tryting to use PostMan, and get the following in the PostMan console:

GET http://tester2.local/api-v2/login

Error: Parse Error: Expected HTTP/

Request Headers
User-Agent: PostmanRuntime/7.28.4
Accept: */*
Postman-Token: 1e8bfce2-e10a-42c6-8b7e-5fcc25d81ade
Host: tester2.local
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Cookie: PHPSESSID=f06cde50cb3bc3a0cc95650df21b3738

When I am testing with curl, it works just fine and gives correct HTTP headers:

curl -v http://tester2.local/api-v2/login
*   Trying 10.10.10.1:80...
* TCP_NODELAY set
* Connected to tester2.local (10.10.10.1) port 80 (#0)
> GET /api-v2/login HTTP/1.1
> Host: tester2.local
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Thu, 25 Nov 2021 14:24:39 GMT
< X-Powered-By: PHP/7.4.13
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Pragma: no-cache
< cache-control: no-store, no-cache, must-revalidate, max-age=0
< content-security-policy: frame-ancestors 'self'
< Access-Control-Allow-Origin: http://localhost:5000
< Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept, Origin, Authorization, Set-Cookie
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Methods: GET, POST, PUT, DELETE, PATCH, OPTIONS
< Set-Cookie: PHPSESSID=ec28d265294aeda1817f0d1695b82393; path=/; domain=.tester2.local; HttpOnly
< Content-Length: 11
< Content-Type: application/json
< 
* Excess found in a read: excess = 27, size = 11, maxdownload = 11, bytecount = 0
* Connection #0 to host tester2.local left intact
{"ok":true}

alex-scott avatar Nov 25 '21 14:11 alex-scott

The same here. I'm trying this small php script under nginx which works fine via curl or hoppscotch but fails with postman.

$ curl -vX POST http://localhost:8088/home/xyz/abc124
*   Trying 127.0.0.1:8088...
* Connected to localhost (127.0.0.1) port 8088 (#0)
> POST /home/xyz/abc124 HTTP/1.1
> Host: localhost:8088
> User-Agent: curl/7.80.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Host: localhost:8088
< Date: Sun, 26 Dec 2021 22:04:06 GMT
< Connection: close
< x-header-one: Header Value 1
< x-header-two: Header Value 2
< content-type: application/json
< content-length: 23
< 
* Closing connection 0
{"some_data":223424234}

joseluisq avatar Dec 26 '21 22:12 joseluisq

The same here. I'm trying this small php script under nginx which works fine via curl or hoppscotch but fails with postman.

$ curl -vX POST http://localhost:8088/home/xyz/abc124
*   Trying 127.0.0.1:8088...
* Connected to localhost (127.0.0.1) port 8088 (#0)
> POST /home/xyz/abc124 HTTP/1.1
> Host: localhost:8088
> User-Agent: curl/7.80.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Host: localhost:8088
< Date: Sun, 26 Dec 2021 22:04:06 GMT
< Connection: close
< x-header-one: Header Value 1
< x-header-two: Header Value 2
< content-type: application/json
< content-length: 23
< 
* Closing connection 0
{"some_data":223424234}

Correcting my previous comment. I was using a dev server and an old postman version. However if I use a latest postman like 9.6.1 as well as a proper server like Nignx my requests work with no this postman issue.

joseluisq avatar Dec 26 '21 22:12 joseluisq

Bug, when trying to send connection request to socket.io server through postman(last version on desktop the same):


logs:


[13194][1645654722816][main][error]["Postman Agent~Main~UncaughtException",{"name":"TypeError","message":"object null is not iterable (cannot read property Symbol(Symbol.iterator))","stack":"TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))\n at Socket.<anonymous> (/Applications/Postman Agent.app/Contents/Resources/app.asar/lib/common/services/SocketIOClient.js:190:15)\n at Object.onceWrapper (events.js:422:26)\n at Socket.emit (events.js:327:22)\n at addChunk (internal/streams/readable.js:309:12)\n at readableAddChunk (internal/streams/readable.js:284:9)\n at Socket.Readable.push (internal/streams/readable.js:223:10)\n at TCP.onStreamRead (internal/stream_base_commons.js:188:23)"}]


(desktop clients shuts after this error)

Responce:


Could not connect to http://localhost:8080/admin 00:23:13 Error: Parse Error: Expected HTTP/ Handshake Details Request URL: http://localhost:8080/api/v1/private/ws/?EIO=4&transport=websocket Request Method: GET Request Headers Sec-WebSocket-Version: 13 Sec-WebSocket-Key: qKBpW+sPUeQko22j38d6gw== Connection: Upgrade Upgrade: websocket Authorization: auth Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits Host: localhost:8080


Pls fix)))

image

shutuper avatar Feb 23 '22 22:02 shutuper

I have the same issue

nickhoeferpickpro avatar Aug 26 '22 18:08 nickhoeferpickpro

Same issue here

lptarik avatar Sep 21 '22 08:09 lptarik

Same issue here

When adding a this header to a server response: header('Content-Length: ' . strlen($fileContent)); - error in Postman Without this header and when opened in a browser - everything is ok

image

ale-lit avatar Oct 05 '22 14:10 ale-lit

@ale-lit @lptarik @nickhoeferpickpro Can you please share the CURL output of these requests? This issue generally pops up for customized HTTP responses (including headers) which do not follow corresponding RFCs.

shubhbhargav avatar Oct 10 '22 00:10 shubhbhargav

@shubhbhargav hi!

After updating postman the problem seems to be gone 👍

ale-lit avatar Oct 10 '22 07:10 ale-lit

Thanks for the confirmation @ale-lit . We will wait for a few weeks to see if anyone else is facing this issue anymore. If not, we will close it. :)

shubhbhargav avatar Oct 10 '22 18:10 shubhbhargav