[ Pobierz całość w formacie PDF ]
.On theother hand, both GET and POST can be used to pass data to the object indi-cated by the URL.When GETis used for this purpose, the data is included inthe URL as the argument string; in order to extract this data with Win-CGI,you have to parse the argument string.When POST is used, the data ispassed to the server in the body of the request message.So, in cases inwhich data is sent to the server, GET and POST differ in the method used totransmit that data.Form SubmissionA user enters input into the fields of a form.When the form is submitted, the datacontained in each field of the form is transferred to the server, which then passesit to ASP.This data is sent in the format name=value, where name is the nameassigned to the field by the NAME= attribute of the tag, and value is thevalue entered in that field.For example, if the user enters Archie in a fieldprompting for his first name, the browser may send along the string first_name=Archie.If the form is written to use METHOD=GET, the form data is appended to the URL asan argument string.If the form contains many fields or if fields contain long stringsof text, the complete URL can become very large and unwieldy.In addition, thelimit of the number of characters submitted in a GET typically about 2000 ismuch lower than in a POST.If the form instead uses METHOD=POST, the name=value pairs are sent as the bodyof the request instead of being appended to the URL.In addition to the greaterease of handling of POST requests, most servers offer better performance whenextracting data from the body of a request than from a URL in the request header.Always use the POST method with forms that change something or cause any irre-versible action (most do).POST is safer and more efficient; GET should never beused to change anything.In developing your ASP scripts, you can decide whetheryou want to support data passed to your program using the GET method.How HTTP Works 53ASP in a Nutshell: A Desktop Quick Reference, eMatter EditionCopyright © 2000 O Reilly & Associates, Inc.All rights reserved.How HTTP WorksHTTP Request and ResponseHeaders are the most misunderstood part of HTTP, yet understanding their rolecan make understanding the properties and methods of both the ASP Request andResponse objects much easier.Take a look at any Internet email message.It consists of two parts, the header andthe body.The header consists of several lines that describe the body of themessage and perhaps the way the message was handled as it was routed to you.The header and body are separated by a blank line.(For more information onheader syntax, consult RFC-822.)An HTTP message (either a request or a response) is structured the same way.Thefirst line is special, but the rest of the lines up to the first blank line are headersjust like in a mail message.The header describes the request and its content, ifany, or the response and its content.The requestIn an earlier section, HTTP: A Simple Example, we saw a number of requestsfrom the browser.Here is another example of a simple HTTP request:POST /cgi-win/hello.exe HTTP/1.0Accept: image/gif, image/jpeg, */*User-Agent: Mozilla/2.0N (Windows; I; 32Bit)Content-type: application/x-www-form-urlencodedContent-length: 14[mandatory blank line]name=Jayne+DoeThe first line, which is known as the request-line, describes the type of request (ormethod) in this case POST, the URL, and, finally, the version of the HTTPprotocol that the client uses.The second line describes the types of documentsthat the client can accept.The third line is an extra header that s not required byHTTP.It gives the name and version of the client software.Following this, asdiscussed in the section HTTP: A Simple Example, are two lines describing theinformation contained in the body of the request.Everything up to the mandatory blank line is part of the HTTP request header.Inaddition to the example lines here, there can be other lines in this section
[ Pobierz całość w formacie PDF ]