Skip to content

Commit

Permalink
Refactor status codes to separate file. Closes #27.
Browse files Browse the repository at this point in the history
  • Loading branch information
Raathigesh committed Jul 16, 2016
1 parent 4bd8be3 commit bf1efea
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 150 deletions.
154 changes: 4 additions & 150 deletions src/client/components/http/ResponseCode.jsx
Original file line number Diff line number Diff line change
@@ -1,157 +1,11 @@
import React, {Component, PropTypes} from 'react';
import responseCodes from '../../stores/httpStatusCodes';

class ResponseCode extends Component {
constructor(props) {
super(props);
this.state = {
responseCodes: [{
label: '100 Continue',
value: '100'
}, {
label: '101 Switching Protocol',
value: '101'
}, {
label: '200 OK',
value: '200'
}, {
label: '201 Created',
value: '201'
}, {
label: '202 Accepted',
value: '202'
}, {
label: '203 Non-Authoritative Information',
value: '203'
}, {
label: '204 No Content',
value: '204'
}, {
label: '205 Reset Content',
value: '205'
}, {
label: '206 Partial Content',
value: '206'
}, {
label: '300 Multiple Choice',
value: '300'
}, {
label: '301 Moved Permanently',
value: '301'
}, {
label: '302 Found',
value: '302'
}, {
label: '303 See Other',
value: '303'
}, {
label: '304 Not Modified',
value: '304'
}, {
label: '305 Use Proxy',
value: '305'
}, {
label: '307 Temporary Redirect',
value: '307'
}, {
label: '308 Permanent Redirect',
value: '308'
}, {
label: '400 Bad Request',
value: '400'
}, {
label: '401 Unauthorized',
value: '401'
}, {
label: '402 Payment Required',
value: '402'
}, {
label: '403 Forbidden',
value: '403'
}, {
label: '404 Not Found',
value: '404'
}, {
label: '405 Method Not Allowed',
value: '405'
}, {
label: '406 Not Acceptable',
value: '406'
}, {
label: '407 Proxy Authentication Required',
value: '407'
}, {
label: '408 Request Timeout',
value: '408'
}, {
label: '409 Conflict',
value: '409'
}, {
label: '410 Gone',
value: '410'
}, {
label: '411 Lenght Required',
value: '411'
}, {
label: '412 Precondition Failed',
value: '412'
}, {
label: '413 Payload Too Large',
value: '413'
}, {
label: '414 URI Too Long',
value: '414'
}, {
label: '415 Unsupported Media Type',
value: '415'
}, {
label: '416 Requested Range Not Satisfiable',
value: '416'
}, {
label: '417 Expectation Failed',
value: '417'
}, {
label: '418 I\'m a teapot',
value: '418'
}, {
label: '421 Misdirected Request',
value: '421'
}, {
label: '426 Upgrade Required',
value: '426'
}, {
label: '428 Precondition Required',
value: '428'
}, {
label: '429 Too Many Requests',
value: '429'
}, {
label: '431 Request Header Fields Too Large',
value: '431'
}, {
label: '500 Internal Server Error',
value: '500'
}, {
label: '501 Not Implemented',
value: '501'
}, {
label: '502 Service Unavailable',
value: '502'
}, {
label: '504 Gateway Timeout',
value: '504'
}, {
label: '505 HTTP Version Not Supported',
value: '505'
}, {
label: '506 Variant Also Negotiates',
value: '506'
}, {
label: '507 Variant Also Negotiates',
value: '507'
}, {
label: '511 Network Authentication Required',
value: '511'
}]
responseCodes: responseCodes
}
}
componentDidMount() {
Expand All @@ -165,7 +19,7 @@ class ResponseCode extends Component {
getLabel = (value) => {
for (let code of this.state.responseCodes) {
if (code.value === value) {
return code.label;
return `${code.value} ${code.label}`;
}
}
}
Expand All @@ -177,7 +31,7 @@ class ResponseCode extends Component {
render() {
let items = this.state.responseCodes.map((responseCode) => {
return (<div className="item" onClick={() => { this.handleOnChange(responseCode.value) } }>
{responseCode.label}
{`${responseCode.value} ${responseCode.label}`}
</div>);
});

Expand Down
150 changes: 150 additions & 0 deletions src/client/stores/httpStatusCodes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
export default [
{
label: 'Continue',
value: '100'
}, {
label: 'Switching Protocol',
value: '101'
}, {
label: 'OK',
value: '200'
}, {
label: 'Created',
value: '201'
}, {
label: 'Accepted',
value: '202'
}, {
label: 'Non-Authoritative Information',
value: '203'
}, {
label: 'No Content',
value: '204'
}, {
label: 'Reset Content',
value: '205'
}, {
label: 'Partial Content',
value: '206'
}, {
label: 'Multiple Choice',
value: '300'
}, {
label: 'Moved Permanently',
value: '301'
}, {
label: 'Found',
value: '302'
}, {
label: 'See Other',
value: '303'
}, {
label: 'Not Modified',
value: '304'
}, {
label: 'Use Proxy',
value: '305'
}, {
label: 'Temporary Redirect',
value: '307'
}, {
label: 'Permanent Redirect',
value: '308'
}, {
label: 'Bad Request',
value: '400'
}, {
label: 'Unauthorized',
value: '401'
}, {
label: 'Payment Required',
value: '402'
}, {
label: 'Forbidden',
value: '403'
}, {
label: 'Not Found',
value: '404'
}, {
label: 'Method Not Allowed',
value: '405'
}, {
label: 'Not Acceptable',
value: '406'
}, {
label: 'Proxy Authentication Required',
value: '407'
}, {
label: 'Request Timeout',
value: '408'
}, {
label: 'Conflict',
value: '409'
}, {
label: 'Gone',
value: '410'
}, {
label: 'Lenght Required',
value: '411'
}, {
label: 'Precondition Failed',
value: '412'
}, {
label: 'Payload Too Large',
value: '413'
}, {
label: 'URI Too Long',
value: '414'
}, {
label: 'Unsupported Media Type',
value: '415'
}, {
label: 'Requested Range Not Satisfiable',
value: '416'
}, {
label: 'Expectation Failed',
value: '417'
}, {
label: 'I\'m a teapot',
value: '418'
}, {
label: 'Misdirected Request',
value: '421'
}, {
label: 'Upgrade Required',
value: '426'
}, {
label: 'Precondition Required',
value: '428'
}, {
label: 'Too Many Requests',
value: '429'
}, {
label: 'Request Header Fields Too Large',
value: '431'
}, {
label: 'Internal Server Error',
value: '500'
}, {
label: 'Not Implemented',
value: '501'
}, {
label: 'Service Unavailable',
value: '502'
}, {
label: 'Gateway Timeout',
value: '504'
}, {
label: 'HTTP Version Not Supported',
value: '505'
}, {
label: 'Variant Also Negotiates',
value: '506'
}, {
label: 'Variant Also Negotiates',
value: '507'
}, {
label: 'Network Authentication Required',
value: '511'
}
];

0 comments on commit bf1efea

Please sign in to comment.