Skip to content

Instantly share code, notes, and snippets.

@nicolasdao
Last active May 2, 2024 02:14
Show Gist options
  • Save nicolasdao/6e4d5727643e6472ef60ad16d51f4c78 to your computer and use it in GitHub Desktop.
Save nicolasdao/6e4d5727643e6472ef60ad16d51f4c78 to your computer and use it in GitHub Desktop.
HTTP protocol. Keywords: http code url

HTTP PROTOCOL & CODES

Table of contents

URL

URLs are broken down as follow:

[href] e.g., https://fonts.gstatic.com/s/flUhRq6tzZclQEJ.woff2?name=frank#footer

where href is broken down as:

[origin][pathname][search][hash]

where:

  • origin: https://fonts.gstatic.com, which can also be broken down as follow:
    • protocol: https:
    • host: fonts.gstatic.com, which can also br broken down as follow:
      • hostname: fonts.gstatic.com
      • port: null, which means 80
  • pathname: /s/flUhRq6tzZclQEJ.woff2
  • search: ?name=frank
  • hash: #footer

Codes

  • 400:
    • Name: Bad Request
    • Main reasons:
      • Missing arguments (for valid argument with incorrect value, use 422 instead).
    • Description: The request signature is incorrect. Use this when the arguments passed to the web method are missing.
  • 401:
    • Name: Unauthorized
    • Main reasons:
      • Missing credentials.
    • Description: The request cannot be processed because it is missing credentials.
  • 403:
    • Name: Forbidden
    • Main reasons:
      • Invalid credentials.
    • Description: The request cannot be processed because its credentials are misisng the right authorization.
  • 422:
    • Name: Unprocessable Entity
    • Main reasons:
      • Incorrect argument's value.
    • Description: Contrary to 400, the request signature is correct, but the arguments passed to the web method are not processable by the system.
  • 301, 302, 307, 308:
    • Permanent vs. Temporary: If the change is permanent, use 301 or 308. For temporary changes, use 302 or 307.
    • Method Preservation: If it's crucial to maintain the HTTP method for the request, choose 307 or 308 over 301 or 302.
    • SEO Considerations: For SEO purposes, permanent redirects (301 or 308) are preferable as they signal search engines to update their indexing to the new URL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment