@@ -52,6 +52,7 @@ export default class ResponseBody extends React.PureComponent {
5252 let { content, contentType, url, headers= { } , getComponent } = this . props
5353 const { parsedContent } = this . state
5454 const HighlightCode = getComponent ( "highlightCode" )
55+ const downloadName = "response_" + new Date ( ) . getTime ( )
5556 let body , bodyEl
5657 url = url || ""
5758
@@ -100,19 +101,19 @@ export default class ResponseBody extends React.PureComponent {
100101 body = "can't parse JSON. Raw result:\n\n" + content
101102 }
102103
103- bodyEl = < HighlightCode downloadable value = { body } />
104+ bodyEl = < HighlightCode downloadable fileName = { ` ${ downloadName } .json` } value = { body } />
104105
105106 // XML
106107 } else if ( / x m l / i. test ( contentType ) ) {
107108 body = formatXml ( content , {
108109 textNodesOnSameLine : true ,
109110 indentor : " "
110111 } )
111- bodyEl = < HighlightCode downloadable value = { body } />
112+ bodyEl = < HighlightCode downloadable fileName = { ` ${ downloadName } .xml` } value = { body } />
112113
113114 // HTML or Plain Text
114115 } else if ( lowerCase ( contentType ) === "text/html" || / t e x t \/ p l a i n / . test ( contentType ) ) {
115- bodyEl = < HighlightCode downloadable value = { content } />
116+ bodyEl = < HighlightCode downloadable fileName = { ` ${ downloadName } .html` } value = { content } />
116117
117118 // Image
118119 } else if ( / ^ i m a g e \/ / i. test ( contentType ) ) {
@@ -126,7 +127,7 @@ export default class ResponseBody extends React.PureComponent {
126127 } else if ( / ^ a u d i o \/ / i. test ( contentType ) ) {
127128 bodyEl = < pre > < audio controls > < source src = { url } type = { contentType } /> </ audio > </ pre >
128129 } else if ( typeof content === "string" ) {
129- bodyEl = < HighlightCode downloadable value = { content } />
130+ bodyEl = < HighlightCode downloadable fileName = { ` ${ downloadName } .txt` } value = { content } />
130131 } else if ( content . size > 0 ) {
131132 // We don't know the contentType, but there was some content returned
132133 if ( parsedContent ) {
@@ -136,7 +137,7 @@ export default class ResponseBody extends React.PureComponent {
136137 < p className = "i" >
137138 Unrecognized response type; displaying content as text.
138139 </ p >
139- < HighlightCode downloadable value = { parsedContent } />
140+ < HighlightCode downloadable fileName = { ` ${ downloadName } .txt` } value = { parsedContent } />
140141 </ div >
141142
142143 } else {
0 commit comments