Label diatas, hom

06/08/2023

HTTP Status Codes

HTTP Status Codes


HTTP Response Codes digunakan untuk menunjukkan keberhasilan, kegagalan, dan lainnya mengenai hasil permintaan HTTP. Terlepas dari body HTTP response message, client akan bertindak sesuai dengan response status code.



Setiap HTTP response disertai dengan kode status, dan dibagi menjadi lima kategori. Setiap kode status respons digunakan untuk menyampaikan informasi umum tentang hasil permintaan.

Ada lima kategori utama kode HTTP response, terdiri dari 3 digit masing-masing dapat diidentifikasi dengan digit pertama:

1xx: Informational
2xx: Success
3xx: Redirection
4xx: Client error
5xx: Server error




Contoh Kasus :

============
Request

PUT /docs HTTP/1.1
Host: www.example.re
Content-Type: application/pdf
Content-Length: 99000
Expect: 100-continue

Response

HTTP/1.1 100 Continue

=========
Response

HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Length: 10000

<message body will contain the requested PDF document>



===========
Request

GET /news.html HTTP/1.1
Host: www.example.re

Response

HTTP/1.1 301 Moved Permanently
Location: http//www.example.re/feeds/news.html
Content-Type: text/html; charset=UTF-8
Content-Length: 150

<h1>The Newsfeed has moved</h1>
<body>
The newsfeed has moved permanently to <a href=/feeds/news.html>here</a>. Please update your bookmarks.
</body>



=====
Request==

DELETE /policies.pdf HTTP/1.1
Host: www.example.re

Response

HTTP/1.1 405 Method Not Allowed
Allow: GET, HEAD, OPTIONS
Content-Type: text/html
Content-Length: 157

<html>
  <head>
    <title>Operation Not Permitted</title>
  </head>
  <body>
    <p>This resource is read-only and cannot be deleted.</p>
  </body>
</html>


===
Request

GET /news HTTP/1.1
Host: www.example.re

Response

HTTP/1.1 502 Bad Gateway
Content-Type: text/html; charset=UTF-8
Content-Length: 134

<html>
  <head>
    <title>Bad Gateway<\title>
  </head>
  <body>
    <p>The server is unreachable at this time.</p>
  </body>
</html>





Tidak ada komentar:

Posting Komentar