mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-25 16:55:59 +03:00
[GH-ISSUE #869] Response content-type as text/html with content in json cause content area display empty #298
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#298
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @BLumia on GitHub (May 13, 2020).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/869
Originally assigned to: @AndrewBastin on GitHub.
Describe the bug
When the returend content-type is
text/plainortext/htmlbut the actual content is a json, the preview shows empty.To Reproduce
I did a quick and dirty server side demo implementation in go:
Do compile it (
go compile main.go) and run it, then request the following address:http://127.0.0.1:4000/: response "text/html" as content-type, preview is empty.http://127.0.0.1:4000/plain: response "text/plain" as content-type, preview is empty.http://127.0.0.1:4000/json: response "application/json" as content-type, preview is expected.Also, when the preview is empty, try toggle "Preview HTML" button, then it will show a
[object Object], but "Download File" icon button can download the actual response content.Expected behavior
When response content-type is html or plain, the preview area should able to at least show the raw content instead of shows empty.
Screenshots
Following image is what it shows when request
http://127.0.0.1:4000/with the above demo server program running.Desktop (please complete the following information):
Let me know if you need any additional context to resolve this issue. Hope that helps.
@liyasthomas commented on GitHub (May 13, 2020):
@BLumia commented on GitHub (May 13, 2020):
It's in real life. I just got this issue today with an endpoint return
text/htmlwith a json content. Since that service is not exposed to public usage so I cannot link the real API here, sorry about that.I agree that endpoint implementation might not do the best practice, but still, I do think the content area in postwoman should at least display the raw content if the content-type is
text/htmlortext/plain, instead of display a[object Object]...@liyasthomas commented on GitHub (May 13, 2020):
Issue has been acknowledged. I'm working on a fix.
@AndrewBastin commented on GitHub (May 18, 2020):
@liyasthomas are you working on this ?
Else I will take it up ^_^
@liyasthomas commented on GitHub (May 18, 2020):
@AndrewBastin Actually I couldn't find why this behaviour happened. The contents passed to the editor seems to be receiving an
objecttype. You can look into it.@AndrewBastin commented on GitHub (May 18, 2020):
I am working on it.
Seems like it is a weird Ace Editor bug.EDIT: Well, upon on further investigation, it is due to the default behaviour of axios to try parsing the JSON even if the content-type doesn't say it is JSON
@AndrewBastin commented on GitHub (May 19, 2020):
This bug is caused due to the default behaviour of axios to take string responses and try to parse them to JSON objects even if the content type is not for a JSON response.
So, when a valid returned eventhough it is set to
text/plain, it will try parsing it and get the JSON object. Then Postwoman can't figure out what to do with JSON object, causing the issue.This behaviour is overridden on the update to the AxiosStrategy in my PR (#881).
But, we have to handle it in all the places where we use Axios.
The browser extension will receive the fix to this in the coming days in a 0.7 update.
UPDATE: Browser extension version 0.7 is live on Firefox and Chrome
Meanwhile, if the proxy uses axios, that should be handled as well @NBTX .
@AndrewBastin commented on GitHub (Jun 15, 2020):
@NBTX, I haven't personally tested this with the proxy, but is this an issue on the proxy ?
@liyasthomas ?