しかし,400番台や500番台はエラーだろうと予想できますが,300番台など分からなかったので調べてました.
WikipediaのHTTPステータスコードの一覧に乗っているステータスコードを試しました.
http://ja.wikipedia.org/wiki/HTTP%E3%82%B9%E3%83%86%E3%83%BC%E3%82%BF%E3%82%B9%E3%82%B3%E3%83%BC%E3%83%89
これが結果です.
100 is error 101 is error 102 is error 200 is success 201 is success 202 is success 203 is success 204 is success 205 is success 206 is success 207 is success 226 is success 300 is error 301 is error 302 is error 303 is error 304 is success 305 is error 306 is error 307 is error 400 is error 401 is error 402 is error 403 is error 404 is error 405 is error 406 is error 407 is error 408 is error 409 is error 410 is error 411 is error 412 is error 413 is error 414 is error 415 is error 416 is error 417 is error 418 is error 422 is error 423 is error 424 is error 425 is error 500 is error 501 is error 502 is error 503 is error 504 is error 505 is error 506 is error 507 is error 508 is error 509 is error 510 is error
304だけ300番台なのにsuccessでした.
続きは検証に使用したソースコードです.
CoffeeScriptです.実行する場合はJavaScriptにコンパイルしてNodeを使ってください.
# 検証するHTTPステータスコード statusCodes = [].concat( [100..102] [200..207].concat [226] [300..307] [400..418].concat [422..424], [425] [500..510] ) # Server http = require 'http' server = http.createServer (req, res) => path = req.url.slice 1 expectStatusCode = parseInt path res.writeHead expectStatusCode res.end() server.listen 8080, 'localhost' # Client tryCount = 0 $ = require 'jQuery' results = {} for statusCode in statusCodes ((statusCode) => $.ajax url: 'http://localhost:8080/' + statusCode success: => results[statusCode] = 'success' error: => results[statusCode] = 'error' complete: => tryCount++ if tryCount is statusCodes.length for k, v of results console.log k + ' is ' + v server.close() ) statusCode
0 件のコメント:
コメントを投稿