0.1.1 • Published 5 years ago

mof-statuscode v0.1.1

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

mof-statuscode

mof-statuscode is a middleware of floodesh, it will make a decision whether to execute following middleware according to returned http status code.

Install

npm install mof-statuscode

Usage

const Worker = require("floodesh/worker")
const request = require('mof-request')
const statuscode = require('mof-statuscode')

const worker = new Worker()

worker.use(co.wrap(request(worker.config.downloader))); // make sure the ctx existing before using statuscode
worker.use(co.wrap(statuscode));

There will be 7 cases in mof-statuscode, each case is corresponded with a coping method:

status coderesponse bodyallow to follow redirectcoping method
4XX / 5XXempty buffer-break
4XX / 5XXempty buffer-break
4XX / 5XXbuffer-break
3XX-existbreak
3XX-truebreak
3XX-falsecontinue
2XX--continue

HTTP response status codes

HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:

  1. Informational responses (100–199),
  2. Successful responses (200–299),
  3. Redirects (300–399),
  4. Client errors (400–499),
  5. and Server errors (500–599).

codemessage
100Continue
101Switching Protocols
102Processing
200OK
201Created
202Accepted
203Non-Authoritative Information
204No Content
205Reset Content
206Partial Content
207Multi-Status
208Already Reported
226IM Used
300Multiple Choices
301Moved Permanently
302Found
303See Other
304Not Modified
305Use Proxy
306Switch Proxy
307Temporary Redirect
308Permanent Redirect
400Bad Request
401Unauthorized
402Payment Required
403Forbidden
404Not Found
405Method Not Allowed
406Not Acceptable
407Proxy Authentication Required
408Request Timeout
409Conflict
410Gone
411Length Required
412Precondition Failed
413Request Entity Too Large
414Request-URI Too Long
415Unsupported Media Type
416Requested Range Not Satisfiable
417Expectation Failed
418I'm a teapot
421Misdirected Request
422Unprocessable Entity
423Locked
424Failed Dependency
425Too Early
426Upgrade Required
428Precondition Required
429Too Many Requests
431Request Header Fields Too Large
451Unavailable For Legal Reasons
500Internal Server Error
501Not Implemented
502Bad Gateway
503Service Unavailable
504Gateway Timeout
505HTTP Version Not Supported
506Variant Also Negotiates
507Insufficient Storage
508Loop Detected
510Not Extended
511Network Authentication Required
420Enhance Your Caim
444No Response
450Blocked by Windows Parental Controls
494Request Header Too Large
0.1.1

5 years ago

0.1.0

5 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago