diff --git a/src/core/components/response-body.jsx b/src/core/components/response-body.jsx
index 1ed23405766..4a1e1c21ce4 100644
--- a/src/core/components/response-body.jsx
+++ b/src/core/components/response-body.jsx
@@ -60,11 +60,11 @@ export default class ResponseBody extends React.PureComponent {
if (
(/^application\/octet-stream/i.test(contentType) ||
- (headers["Content-Disposition"] && /attachment/i.test(headers["Content-Disposition"])) ||
- (headers["content-disposition"] && /attachment/i.test(headers["content-disposition"])) ||
- (headers["Content-Description"] && /File Transfer/i.test(headers["Content-Description"])) ||
- (headers["content-description"] && /File Transfer/i.test(headers["content-description"]))) &&
- content.size > 0
+ (headers["Content-Disposition"] && /attachment/i.test(headers["Content-Disposition"])) ||
+ (headers["content-disposition"] && /attachment/i.test(headers["content-disposition"])) ||
+ (headers["Content-Description"] && /File Transfer/i.test(headers["Content-Description"])) ||
+ (headers["content-description"] && /File Transfer/i.test(headers["content-description"]))) &&
+ (content.size > 0 || content.length > 0)
) {
// Download
diff --git a/test/unit/components/response-body.jsx b/test/unit/components/response-body.jsx
index 0d316b6ef0e..8771905f5f7 100644
--- a/test/unit/components/response-body.jsx
+++ b/test/unit/components/response-body.jsx
@@ -28,7 +28,6 @@ describe("", function () {
it("renders ResponseBody as 'image/svg'", function () {
props.contentType = "image/svg"
const wrapper = shallow()
- console.warn(wrapper.debug())
expect(wrapper.find("highlightCodeComponent").length).toEqual(0)
})
@@ -36,17 +35,26 @@ describe("", function () {
props.contentType = "text/plain"
props.content = "test text"
const wrapper = shallow()
- console.warn(wrapper.debug())
expect(wrapper.find("highlightCodeComponent[canCopy]").length).toEqual(1)
})
- it("should render Download file link for non-empty response", function () {
+ it("should render Download file link for non-empty Blob response", function () {
props.contentType = "application/octet-stream"
props.content = new Blob(["\"test\""], { type: props.contentType })
const wrapper = shallow()
expect(wrapper.text()).toMatch(/Download file/)
})
+ it("should render Download file link for non-empty text response", function () {
+ props.contentType = "text/plain"
+ props.content = "test text"
+ props.headers = {
+ "Content-Disposition": "attachment; filename=\"test.txt\"",
+ }
+ const wrapper = shallow()
+ expect(wrapper.text()).toMatch(/Download file/)
+ })
+
it("should not render Download file link for empty response", function () {
props.contentType = "application/octet-stream"
props.content = new Blob()