HTTP Methods

  • GET: Read
  • POST: Create
  • PUT: Update entire object
  • PATCH: Partial update to the object
  • DELETE: Delete
  • OPTIONS: Get supported operations to the resource (Used for preflight)
  • HEAD: Return HTTP header only
  • TRACE: performs a message loop-back test along the path to the target resource, providing a useful debugging mechanism
  • CONNECT: Starts two-way communications with the requested resource

Safe Methods

  • https://developer.mozilla.org/en-US/docs/Glossary/Safe/HTTP
  • It doesn’t alter the state of the server
  • All safe methods are also idempotent
  • Safe Methods include:
    • GET
    • HEAD
    • OPTIONS
    • TRACE
  • Even if safe methods have a read-only semantic, servers can alter their state: e.g. they can log or keep statistics.
  • What is important here is that by calling a safe method, the client doesn’t request any server change itself, and therefore won’t create an unnecessary load or burden for the server.
  • Applications:
    • Browsers can perform pre-fetching without risk.
    • Web crawlers also rely on calling safe methods.
  • For Safe Requests (not safe methods): CORS and Same Origin Policy

Idempotent Methods