Monday, 26 August 2013

What is HTTP methods ? #web

  • Options Get information about how the server allows to communicate with.
  • GET Retrieve a resource.
  • POST Create a new resource.
  • PUT Send data to the server.
  • DELETE Delete an existing resource.
  • TRACE Return the request headers sent by the client.


For Details :


  • OPTIONS Get information about how the server allows to communicate with.
Request:
OPTIONS * HTTP/1.1
Host: example.com
Response:
HTTP/1.1 200 OK
Date: …
Allow: OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE
Content-Length: 0
  • GET Retrieve a resource.
    Request:
    GET /foo/bar HTTP/1.1
    Host: example.com
    
    Response:
    HTTP/1.1 200 OK
    Date: …
    Content-Type: text/html;charset=utf-8
    Content-Length: 12345
     
    <!DOCTYPE …
    
  • HEAD Like GET, but returns just the HTTP header.
    Request:
    HEAD /foo/bar HTTP/1.1
    Host: example.com
    
    Response:
    HTTP/1.1 200 OK
    Date: …
    Content-Type: text/html;charset=utf-8
    Content-Length: 12345
    
  • POST Create a new resource.
    Request:
    POST /foo/bar HTTP/1.1
    Host: example.com
    Content-Type: application/x-www-form-urlencoded
     
    action=addentry&subject=Hello,%20World
    
    Response:
    HTTP/1.1 201 Created
    Date: …
    Content-Length: 0
    Location: http://example.com/foo/bar        
    
  • PUT Send data to the server.
  • DELETE Delete an existing resource.
  • TRACE Return the request headers sent by the client.
    Request:
    TRACE /foo/bar HTTP/1.1
    Host: example.com
    
    Response:
    HTTP/1.1 200 OK
    Date: …
    Content-Length: 17
     
    Host: example.com
    For More Details click here

No comments:

Post a Comment