nazad | soderzhanie | vpered

6 Otvet (Response).

Posle polucheniya i interpretacii soobshcheniya zaprosa, server otvechaet soobshcheniem HTTP otveta.

       Response      = Status-Line               ; Razdel 6.1
                       *( general-header         ; Razdel 4.5
                        | response-header        ; Razdel 6.2
                        | entity-header )        ; Razdel 7.1
                       CRLF
                       [ message-body ]          ; Razdel 7.2

6.1 Stroka sostoyaniya (Status-Line).

Pervaya stroka otveta - eto stroka sostoyaniya (Status-Line). Ona sostoit iz versii protokola (HTTP-Version), chislovogo koda sostoyaniya (Status-Code) i poyasnyayushchej frazy (Reason-Phrase), razdelennyh simvolami SP. CR i LF ne dopustimy v Status-Line, za isklyucheniem konechnoj posledovatel'nosti CRLF.

       Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF

6.1.1 Kod sostoyaniya i poyasnyayushchaya fraza.

|lement kod sostoyaniya (Status-Code) - eto celochislennyj trehrazryadnyj kod rezul'tata ponimaniya i udovletvoreniya zaprosa. |ti kody polnost'yu opredeleny v razdele 10. Poyasnyayushchaya fraza (Reason-Phrase) prednaznachena dlya korotkogo tekstovogo opisaniya koda sostoyaniya. Kod sostoyaniya (Status-Code) prednaznachen dlya ispol'zovaniya avtomatami, a poyasnyayushchaya fraza prednaznachena dlya zhivyh pol'zovatelej. Ot klienta ne trebuetsya issledovat' ili otobrazhat' poyasnyayushchuyu frazu (Reason-Phrase).

Pervaya cifra koda sostoyaniya opredelyaet klass otveta. Poslednie dve cifry ne imeyut opredelennoj roli v klassifikacii. Imeetsya 5 znachenij pervoj cifry:

  1. 1xx: Informacionnye kody - zapros poluchen, prodolzhaetsya obrabotka.
  2. 2xx: Uspeshnye kody - dejstvie bylo uspeshno polucheno, ponyato i obrabotano.
  3. 3xx: Kody perenapravleniya - dlya vypolneniya zaprosa dolzhny byt' predprinyaty dal'nejshie dejstviya.
  4. 4xx: Kody oshibok klienta - zapros imeet plohoj sintaksis ili ne mozhet byt' vypolnen.
  5. 5xx: Kody oshibok servera - server ne v sostoyanii vypolnit' dopustimyj zapros.

Konkretnye znacheniya chislovyh kodov sostoyaniya, opredelennyh v HTTP/1.1, i primernyj nabor sootvetstvuyushchih poyasnyayushchih fraz (Reason-Phrase) privodyatsya nizhe. Poyasnyayushchie frazy (Reason-Phrase), perechislennye zdes' yavlyayutsya rekomenduemymi, no mogut byt' zameneny na ekvivalentnye bez vozdejstviya na protokol.

          Status-Code    = "100"   ; Prodolzhat', Continue
                         | "101"   ; Pereklyuchenie protokolov, Switching Protocols
                         | "200"   ; OK
                         | "201"   ; Sozdan, Created
                         | "202"   ; Prinyato, Accepted
                         | "203"   ; Ne avtorskaya informaciya, Non-Authoritative Information
                         | "204"   ; Net soderzhimogo, No Content
                         | "205"   ; Sbrosit' soderzhimoe, Reset Content
                         | "206"   ; CHastichnoe soderzhimoe, Partial Content
                         | "300"   ; Mnozhestvennyj vybor, Multiple Choices
                         | "301"   ; Postoyanno perenesen, Moved Permanently
                         | "302"   ; Vremenno peremeshchen, Moved Temporarily
                         | "303"   ; Smotret' drugoj, See Other
                         | "304"   ; Ne modificirovan, Not Modified
                         | "305"   ; Ispol'zujte proksi-server, Use Proxy
                         | "400"   ; Isporchennyj Zapros, Bad Request
                         | "401"   ; Nesankcionirovanno, Unauthorized
                         | "402"   ; Trebuetsya oplata, Payment Required
                         | "403"   ; Zapreshcheno, Forbidden
                         | "404"   ; Ne najden, Not Found
                         | "405"   ; Metod ne dozvolen, Method Not Allowed
                         | "406"   ; Ne priemlem, Not Acceptable
                         | "407"   ; Trebuetsya ustanovlenie podlinnosti cherez
                                   ; proksi-server, Proxy Authentication Required
                         | "408"   ; Isteklo vremya ozhidaniya zaprosa, Request Timeout
                         | "409"   ; Konflikt, Conflict
                         | "410"   ; Udalen, Gone
                         | "411"   ; Trebuetsya dlina, Length Required
                         | "412"   ; Preduslovie neverno, Precondition Failed
                         | "413"   ; Ob容kt zaprosa slishkom bol'shoj, Request Entity Too
                                   ; Large
                         | "414"   ; URI zaprosa slishkom dlinnyj, Request-URI Too Long
                         | "415"   ; Nepodderzhivaemyj media tip, Unsupported Media Type
                         | "500"   ; Vnutrennyaya oshibka servera, Internal Server Error
                         | "501"   ; Ne realizovano, Not Implemented
                         | "502"   ; Oshibka shlyuza, Bad Gateway
                         | "503"   ; Servis nedostupen, Service Unavailable
                         | "504"   ; Isteklo vremya ozhidaniya ot shlyuza, Gateway Timeout
                         | "505"   ; Ne podderzhivaemaya versiya HTTP, HTTP Version Not
                                   ; Supported
                         | extension-code

          extension-code = 3DIGIT

          Reason-Phrase  = *<TEXT ne vklyuchayushchij CR, LF>

Kody sostoyaniya HTTP rasshiryaemy. HTTP prilozheniyam ne trebuetsya ponimat' znachenie vseh zaregistrirovannyh kodov sostoyaniya, hotya takoe ponimanie ochen' zhelatel'no. Odnako, prilozheniya DOLZHNY ponimat' klass lyubogo koda sostoyaniya, kotoryj oboznachaetsya pervoj cifroj, i obrabatyvat' lyuboj neraspoznannyj otvet kak ekvivalentnyj kodu sostoyaniya x00 etogo klassa, za isklyucheniem teh sluchaev, kogda neraspoznannyj otvet NE DOLZHEN keshirovat'sya. Naprimer, esli klientom poluchen i ne byl raspoznan kod sostoyaniya 431, to on mozhet bezopasno schitat', chto v zaprose chto-to bylo nepravil'no i obrabatyvat' otvet, kak esli by byl poluchen kod sostoyaniya 400. V takih sluchayah agentam pol'zovatelya SLEDUET predstavit' pol'zovatelyu ob容kt, vozvrashchennyj v otvete, tak kak etot ob容kt, veroyatno, vklyuchaet chitabel'nuyu dlya cheloveka informaciyu, kotoraya poyasnyaet neobychnoe sostoyanie.

6.2 Polya zagolovka otveta.

Polya zagolovka otveta (response-header fields) pozvolyayut serveru peredavat' dopolnitel'nuyu informaciyu, kasayushchuyusya otveta, kotoraya ne mozhet byt' pomeshchena v stroku sostoyaniya Status-Line. |ti polya zagolovka dayut informaciyu o servere i o dal'nejshem dostupe k resursu, ukazannomu etim Request-URI.

          response-header = Age                     ; Razdel 14.6
                          | Location                ; Razdel 14.30
                          | Proxy-Authenticate      ; Razdel 14.33
                          | Public                  ; Razdel 14.35
                          | Retry-After             ; Razdel 14.38
                          | Server                  ; Razdel 14.39
                          | Vary                    ; Razdel 14.43
                          | Warning                 ; Razdel 14.45
                          | WWW-Authenticate        ; Razdel 14.46

Imena polej zagolovka otveta (Response-header) mogut byt' nadezhno rasshireny tol'ko v sochetanii s izmeneniem versii protokola. Odnako, novye ili eksperimental'nye polya zagolovka mogut poluchit' semantiku polej zagolovka otveta (Response-header), esli vse storony soedineniya raspoznayut ih kak polya zagolovka otveta (Response-header). Neraspoznannye polya zagolovka obrabatyvayutsya kak polya zagolovka ob容kta (entity-header).

Mnozhestvo imen polej zagolovka otveta (Response-header) mozhet byt' nadezhno rasshireno tol'ko v kombinacii s izmeneniem versii protokola. Odnako, novye ili eksperimental'nye polya zagolovka s semantikoj polej zagolovka otveta MOGUT byt' dobavleny esli vse uchastniki soedineniya raspoznayut ih kak polya zagolovka otveta. Neraspoznannye polya zagolovka obrabatyvayutsya kak polya zagolovka ob容kta.


Copyright  ©  1998 Alex Simonoff (http://www.omsk.com/Leshik/), All Rights Reserved.


nazad | soderzhanie | vpered