ensure live-response headers exist

This commit is contained in:
Josh Ponelat
2017-03-19 08:37:56 +02:00
parent 3fe3f0bfdb
commit 2479b8cdde
2 changed files with 17 additions and 12 deletions

View File

@@ -20,21 +20,23 @@ export default class LiveResponse extends React.Component {
} }
render() { render() {
let { request, response, getComponent } = this.props const { request, response, getComponent } = this.props
const body = response.get("text")
const status = response.get("status")
const url = response.get("url")
const headers = response.get("headers").toJS()
const notDocumented = response.get("notDocumented")
const isError = response.get("error")
const headersKeys = Object.keys(headers)
const contentType = headers["content-type"]
const Curl = getComponent("curl") const Curl = getComponent("curl")
let body = response.get("text") const ResponseBody = getComponent("responseBody")
let status = response.get("status") const returnObject = headersKeys.map(key => {
let url = response.get("url")
let originalHeaders = response.get("headers")
let headers = originalHeaders && originalHeaders.toJS()
let headersKeys = Object.keys(headers)
let returnObject = headersKeys.map(key => {
return <span className="headerline" key={key}> {key}: {headers[key]} </span> return <span className="headerline" key={key}> {key}: {headers[key]} </span>
}) })
let notDocumented = response.get("notDocumented")
let ResponseBody = getComponent("responseBody")
let contentType = headers && headers["content-type"]
let isError = response.get("error")
return ( return (
<div> <div>

View File

@@ -84,6 +84,9 @@ export default {
result = res result = res
} }
// Ensure headers
result.headers = result.headers || {}
let newState = state.setIn( [ "responses", path, method ], fromJSOrdered(result) ) let newState = state.setIn( [ "responses", path, method ], fromJSOrdered(result) )
// ImmutableJS messes up Blob. Needs to reset its value. // ImmutableJS messes up Blob. Needs to reset its value.