HTTP: Difference between revisions
| Line 85: | Line 85: | ||
Accept Liste der MIME Types, die der client versteht<br> | Accept Liste der MIME Types, die der client versteht<br> | ||
Authorization | Authorization <br> | ||
From | From <br> | ||
If modified since | If modified since<br> | ||
Referer | Referer <br> | ||
User Agent | User Agent <br> | ||
Entity Header | Entity Header <br> | ||
Allow | Allow <br> | ||
Content-encoding | Content-encoding<br> | ||
Content-length | Content-length <br> | ||
Content-type | Content-type <br> | ||
expires | expires <br> | ||
Revision as of 22:16, 5 May 2007
Basics
HTTP (hypertext transport protocol; die aktuelle Version ist 1.1) is a protocol with the lightness and speed necessary for a distributed collaborative hypermedia information system. It is a generic stateless object-oriented protocol, which may be used for many similar tasks such as name servers, and distributed object-oriented systems, by extending the commands, or "methods", used. A feature if HTTP is the negotiation of data representation, allowing systems to be built independently of the development of new advanced representations. The protocol does not attempt to define what types of resources are transferred. The data may be text, sound, full-motion video, even applications to be executed on the client machine.
The HTTP protocol allows for only a single resource to be transferred during a connection. This means that if a hypertext page has embedded references to other resources (such as images), the client must retrieve each resource individually through separate connections. For example, to construct the Web page of Figure 2.1, the Web browser had to make three connections. One to retrieve the HTML file, another to retrieve the embedded Java applet, and a third to retrieve the Under Construction picture. This shortcoming of HTTP has often been blamed for the slow response time of the Web.
Requests/Repsonses
The HTTP protocol is a request/response protocol. A client sends a request to the server in the form of a request method, URI, and protocol version, followed by a MIME-like message containing request modifiers, client information, and possible body content over a connection with a server. The server responds with a status line, including the message's protocol version and a success or error code, followed by a MIME-like message containing server information, entity metainformation, and possible entity-body content.
HTTP messages can take either a full request/response or a simple request/response message format. HTTP-full-request und full-response kann optionale header und entity-bodies beinhalten. Simple request und simple-response Nachrichten gestatten keine Gebrauch der Header-Informationen und sind auf das Abrufen eines entity bodies beschränkt.
Requests
Full Request haben grundsätzlich folgenden Aufbau:
<Request-Line> <General-Header> <Request-Header> <Entity-Header><CRLF> <Entity-Body>
Es gelten folgende Regeln:
<Request-Line> := <Method><SPACE><Request-URI><SPACE><HTTP-Version><CRLF>
Responses
Die Response hat folgenden Aufbau:
<Status-Line> <General-Header> <Response-Header> <Entity-Header><CRLF> <Entity-Body>
Eine einzelne HTTP-Operation nennt man Transaktion. Beim Gebrauch von HTTP bestimmen client und server die Dokumentformate dynamisch. D.h. wenn ein Browser ein Server kontaktiert, sendet der Browser dem server eine Liste von Formaten, die dieser erkennt. Im Prinzip handelt es sich um eine 4-Schritt Transaktion: 1. Einrichten einer Verbindung 2. Client sendet eine Anforderung in Form einer method gefolgt von einer Objekt URL und der HTTP-Protokoll Version 3. Der Server gibt ein Antwort in Form der HTTP-Protokoll Version, einem dreistelligen Statuscode und einer Plausibilitätsphrase 4. Der Server beendet die Verbindung
Die Response-Codes werden in 5 Klassen unterteilt:
1xx Informierend (z.Z. nicht benutzt) 2xx Erfolg 3xx Es müssen noch weitere Maßnahmen getroffen werden 304 not-modified 4xx Client-Fehler 401 nicht authorisierte Anforderung 403 forbidden access 404 not-found 407 Proxy Authentication Required 5xx Server-Fehler 501 not implemented
HTTP bezieht sich auf seine Befehle als Verfahrensweise bzw. Methode. Die Methode nennt dem server die Anordnung, die er bei der Datenquelle auszuführen hat. Es gibt eigentlich drei wichtige Methoden:
GET Methode
Die HTTP GET Methode fordert einen Web-Server auf, Informationen einzuholen, die die URI beschreibt. Die GET-Methode wird zu einem Conditional GET, wenn die Anfoderung, die der client sendet, ein if modified since Header-Feld enthält.
HEAD-Methode
Die HTTP-HEAD Methode ist fast mit GET identisch, mit der Ausnahme, daß der Web-Server beim Antworten kein entity body zurücksendet. Es gibt kein Conditional HEAD.
POST Methode
Die HTTP POST Methode verlangt vom WebServer, das in der Anforderung eingeschlossene Objekt mit der eingeschlossenen URI zu verbinden. Somit schafft oder ersetzt POST eine mit der URL verbundene Datenquelle. Der Server muß die Quelle aber nicht persistent abspeichern und zugreifbar machen.
Weitere Methoden sind CHECKIN, CHECKOUT, DELETE, LINK, PUT, SEARCH, SHOWMETHOD, SPACEJUMP, TEXTSEARCH und UNLINK.
Bei method=post wird die Zeichenkette <Name>=<Value> an den HTTP Anfrage Header und einer Leerzeile angehängt. Dieser String nennt sich auch Querystring.
Querystring
Der Aubau ist
<QueryString> := ?<NameValuePair>{&<NameValuePair>} <NameValuePair> := <Name>=<Value> <Value> := <ValuePart>{+<ValuePart>} <ValuePart> := (<Sonderzeichen> | <Zeichen>) <Sonderzeichen> := %<ASCIINumber>
Header Felder
Accept Liste der MIME Types, die der client versteht
Authorization
From
If modified since
Referer
User Agent
Entity Header
Allow
Content-encoding
Content-length
Content-type
expires