210 likes | 223 Views
Requests and Server Response Codes. Part I - Requests. Two Main Request Types. GET POST Every file is requested by the client using one of these methods. Less Common Request Methods. HEAD Like GET, but only returns the header portion. Useful to verify the document exists.
E N D
Two Main Request Types • GET • POST • Every file is requested by the client using one of these methods.
Less Common Request Methods HEAD Like GET, but only returns the header portion. Useful to verify the document exists. PUT Used to publish documents to the Web. DELETE Deletes the document
Comparing GET and POST • GET appears in the URL (URI). • GET is limited in size. Don’t go over 1000 characters in your URI. • GET can refresh the same page, because the request includes the name value pairs • GET shows passwords in plain sight in the request.
Comparing GET and POST • POST sends form information separately, so refreshing the page may be unsuccessful if the info was not cached. • POST can send more form information
URL Encoding • Sometimes you will see strange symbols up in your URL. Those are URL Encoded symbols matching common characters such as a space or ampersand. That way the request won’t end up confusing the server or client. • My.cgi?example=Kevin%20Harville • For instance, your form input may include an ampersand, equals, or slash. These things have meanings that may cause errors unless interpreted correctly.
Overview • We are used to seeing 403 and 404 errors, indicating “forbidden” and “not found” respectively. • EVERY time the server is requested to serve a file it gives a response code. • The code is given in the response header.
The Most Common Response • The most common response code is 200, meaning the client’s request was successful. • Your header may begin as follows: HTTP/1.1 200 OK Date: Monday, 12-March-01 17:45:91 GMT …..
Response Code Summary • 100-199 Informational • 200-299 Request Successful • 300-399 Redirected. Further Action Necessary. • 400-499 Client Error • 500-599 Server Error
Common 400 Errors • 400 Bad Request • 401 Unauthorized • 403 Forbidden • 404 Not Found • 405 Method Not Allowed • 408 Request Time-out
400 • There was a syntax error in the request
401 • The request lacked proper authorization.
403 • Forbidden • We commonly get this on Gaia when we forget to set our permissions.
404 • The infamous “Not Found” Error. • The file does not exist.
408 • The request timed-out due to client side error.
500 Errors • 500 Internal Server Error • This indicates that a part of the server (for example, a CGI or ASP program) has crashed or encountered a configuration error.
Custom Error Pages • Perhaps you have seen custom error pages. To see one you may wish to type in a URL for a document that does not exist. • A major site will respond with a custom error page for 404 errors. • This page can be just like any other page. • You can configure Apache, IIS, or most other servers to serve custom error pages in response to specific errors.