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

Fix audio response playback for non-GET requests #10228

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/components/live-response.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ export default class LiveResponse extends React.Component {
: null
}
{
body ? <ResponseBody content={ body }
body ? <ResponseBody method={ method }
content={ body }
contentType={ contentType }
url={ url }
headers={ headers }
Expand Down
6 changes: 5 additions & 1 deletion src/core/components/response-body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default class ResponseBody extends React.PureComponent {
}

static propTypes = {
method: PropTypes.string,
content: PropTypes.any.isRequired,
contentType: PropTypes.string,
getComponent: PropTypes.func.isRequired,
Expand Down Expand Up @@ -50,7 +51,7 @@ export default class ResponseBody extends React.PureComponent {
}

render() {
let { content, contentType, url, headers={}, getComponent } = this.props
let { method, content, contentType, url, headers={}, getComponent } = this.props
const { parsedContent } = this.state
const HighlightCode = getComponent("HighlightCode", true)
const downloadName = "response_" + new Date().getTime()
Expand Down Expand Up @@ -135,6 +136,9 @@ export default class ResponseBody extends React.PureComponent {

// Audio
} else if (/^audio\//i.test(contentType)) {
if (method !== "get") {
url = window.URL.createObjectURL(content)
}
bodyEl = <pre className="microlight"><audio controls key={ url }><source src={ url } type={ contentType } /></audio></pre>
} else if (typeof content === "string") {
bodyEl = <HighlightCode downloadable fileName={`${downloadName}.txt`} canCopy>{content}</HighlightCode>
Expand Down