The HttpResponse Object
When the webserver locates the resource it returns the response as HTML ( can be other than HTML). In the response, the webserver adds a HTTP header info and then attaches the response. The response contains HTML.
When the webclient reads the Http response ie http header and when it encounters the HTML, it goes into the HTML rendering mode and displays the HTML to the client. On reading the HTML when the client encounters an IMG SRC tag it again makes a request to the server, gets the resource ( in this case the image) and displays the response to the client.
The MIME type
When a server sends a response, it also sends the information about the type of the response which is send by the server. The webclient on reading this request undustands that the response is of a particular type and displays it in the required manner
eg Content-type : text/html
The HttpRequest Object
The HttpRequest header consists of the following
- Name of the method used to communicate between the client and the server
- The Resource Path
- The parameters required for the resource
- The protocol name
Name of the method:
There are two methods (generally 2 ways) to pass request from the client to the server
- Get
- Post
Get
- The number of parameters passed in GET are limited
- Get is generally used to querry the webserver and get the output, although get can be used to send request data
- URLs used with GET cannot be bookmarked
- The parameters passed in GET can be seen at the address bar when the request is made, thus its not safe.
- Get requests are idempotent, means that a user can do the same thing again and again.(besides Get, Head and PUT are idempotent)
- If a method name is not specified in the method attribute in the form tag then its a get request
POST
- You can pass number of parameters in the POST request.
- The parameters passed in PosT is send as the body of the request.
- POST is used to send the data to the webserver
- URL with post can be bookmarked.
- Post is non idempotent.
- Need to explicitly specify the post request.
No comments:
Post a Comment