`
`MEmanning@cowrncroisemeworo
`
`Covers HTTP/1.1
`
`001
`
`AppleInc.
`APL1115
`U.S. Patent No. 8,724,622
`
`001
`
`Apple Inc.
`APL1115
`U.S. Patent No. 8,724,622
`
`
`
`Illustrated Guide
`toliP
`
`PAUL S. HETHMON
`ef
`
`MANNING
`
`areenwic
`(74° w.long.)
`
`002
`
`
`
`Forelectronic browsing and ordering ofthis book, see http://www.browsebooks.com.
`
`Thepublisher offers discounts on this book whenordered in quantity. For more
`information, please contact:
`
`QA 76
`TE
`"HPEH “PY
`/ G z T
`MRC
`
`Special Sales Department
`Manning Publications Co.
`3 Lewis Street
`
`Greenwich, CT 06830
`
`Fax: (203) 661-9018
`email: orders@manning.com
`
`©1997 by ManningPublications Co.All rights reserved.
`
`Nopart ofthis publication may be reproduced,stored in a retrieval system, or
`transmitted, in any form or by means electronic, mechanical, photocopying, ot
`otherwise, withoutprior written permission of the publisher.
`
`© Recognizing the importance ofpreserving whathas been written,it is
`Manning's policy to have the books it publishes printed on acid-free paper, and
`we exert our best efforts to that end.
`
`Manyofthe designations used by manufacturers andsellers to distinguish their
`products are claimed as trademarks. Where those designations appear in the book,
`and Manning Publications was aware ofa trademark claim, the designations have
`been printed ininitial caps orall caps.
`
`Library of Congress Cataloging-in-Publication Data
`Hethmon, Paul S.
`Illustrated guide to HTTP / Paul S. Hethmon.
`Pp.
`cm.
`Includes bibliographical refrences and index.
`ISBN 1-884777-37-6
`1. Hypertext systems. 2. HTTP (Computer networkprotocol)
`L. Title.
`QA76.76.H94H484 1997
`004.6'2—dc21
`
`97-1596
`CIP
`
`iM Manning Publications Co.
`3 Lewis Street
`Greenwich, CT 06830
`
`Copyeditor: Maggie Mitchell
`Typesetter: Dorothy Marsico
`Cover designer: Leslie Haimes
`
`Printed in the United States of America
`123456789 10 — CR — 00 99 98 97
`
`003
`
`003
`
`
`
`contents
`
`
`Xxti
`preface
`acknowledgments
`
`xiv
`
`1
`
`Introduction 1
`
`kl
`
`1.2
`
`V3
`
`1.4
`
`Is this book for you? 2
`Required background 3
`The material 4
`
`Finishing 6
`
`2 HTTP overview 7
`
`2:1
`
`2.2
`
`BD
`
`2.4
`
`Pies
`
`Whatis the World Wide Web? 8
`Theclient/server model 8
`
`General operation 10
`A bit of history 12
`HTTP/0.9 12, HTTP/1.0 13
`
`HTTP/1.1 16
`Persistent connections 18,
`New request methods 17,
`Chunked encoding 19, Byte range operations 20,
`Contentnegotiation 20, Digest Authentication 21,
`Caching 22
`Finishing 24
`
`vil
`
`004
`
`004
`
`
`
`CONTENTS
`
`
`3 Basic HTTP—syntax and semantics 25
`3.1 Terminology 26
`3.2 Protocol syntax 31
`3.3. The basic grammar 33
`3.4 Basic HTTP concepts 34
`HTTP version 34, Uniform Resource Identifiers 35,
`Formats for date and time 38, Code: date handling 39,
`Character sets 41, Content codings 42, Transfer
`codings 43, Code: chunked encoding 44, Media
`types 47,
`Product tokens 49, Quality values 49,
`Language tags 50, Entity tags 50, Range units 51
`3.5 Finishing 52
`
`4 The request 53
`4.1 The Request Message 54
`4.2 Methoddefinitions 55
`The OPTIONS method 55, The GET method 56, The
`HEAD method 57, The POST method 58, The PUT
`method 59, The DELETE method 60, The TRACE
`method 60
`
`4.3 The request headerfields 61
`Accept 61, Accept-Charset 62, Accept-Encoding 62,
`Accept-Language 62, Authorization 63, Code:
`Base64 64,
`From 67, Host 67,
`IfModified-Since 67,
`IfMatch 68,
`If-None-Match 68,
`If-Range 69,
`IfUnmodified-Since 69, Max-Forwards 69,
`Proxy-Authorization 70, Range 70, Referer 71,
`User-Agent 71
`4.4 Implementation 71
`GET and HEAD 72, POST 78, PUT 80,
`DELETE 81, OPTIONS 81, TRACE 82
`4.5 Finishing 83
`
`vill
`
`005
`
`005
`
`
`
`
`
`CONTENTS
`_———KS
`
`5 Entity andgeneral headers, and cache-control 84
`5.1 The entity headers 85
`Allow 85, Conrent-Base 85, Content-Encoding 86
`Content-Language 86, Content-Length 86,
`Content-Location 87, Content-MD5 87,
`Content-Range 87, Content-Type 88, ETag 88,
`Last-Modified 88
`
`5.2 The general headers 88
`Pragma 89,
`Connection 89, Date 89,
`Transfer-Encoding 89, Upgrade 90, Via 90
`5.3 Cache-Control 91
`Whatis cachable? 93, Age 93, Cache-Control 94,
`Expires 95, Warning 95, Cache operation 96,
`Expiration of responses 99,
`Fresh andstale
`responses 100, Validating a response 101, Examples 103
`5.4 Finishing 105
`
`6 The response 106
`6.1 The response message 107
`6.2 The response headerfields 111
`Accept-Ranges 112, Authentication-info 112,
`Location 113,
`Proxy-Authenticate 113,
`Proxy-Authenticate-info 113,
`Public 113,
`Retry-After 114,
`Server 114, Vary 114,
`Warning 114, WWW-Authenticate 115, Code: Digest
`Access Authentication 115
`
`6.3 Digest Access Authentication 117
`6.4 Implementation 121
`GETand byte range
`GET and HEAD 121,
`requests 124, GET and contentnegotiation 126
`6.5 Finishing 127
`
`006
`
`006
`
`
`
`CONTENTS
`
`
`7 Sockets 128
`
`Pal
`
`72
`
`Fo
`
`7.4
`
`ed
`
`7.6
`
`7.7
`
`7.8
`
`eo
`
`7.10
`
`7.11
`
`The socket 129
`Setting up theserver socket 130
`Setting up theclient socket 134
`Data transmission 136
`
`Utility routines 144
`Host name and address routines 144
`NTspecifics 146
`OS/2 specifics 147
`The socket class 149
`
`The socket class methods 154
`Finishing 173
`
`8
`
`The HTTP/1.1 server 174
`
`8.1
`
`8.2
`
`8.3
`
`8.4
`
`8.5
`
`8.6
`
`8.7
`
`8.8
`
`8.9
`
`8.10
`
`8.11
`
`8.12
`
`8.13
`
`8.14
`
`8.15
`
`Theconfiguration file 175
`The main program 179
`The server 183
`
`The authorization model 187
`Request and response headers 189
`HTTP/1.1 216
`Finding the method 224
`TRACE 225
`
`OPTIONS 229
`
`PUT 230
`
`If functions 238
`Chunked encoding 242
`The DELETE method 247
`GETthe document 254
`Checking the IfRange 265
`
`007
`
`007
`
`
`
`CONTENTS
`
`
`8.16 Transmission of byte ranges 267
`8.17 Finishing 274
`
`9 Common Gateway Interface support 275
`9.1 Basic functions 276
`9.2 Executing the CGI program 287
`9.3. The OS/2 version 289
`
`9.4 The Windows version 299
`9.5 Finishing 308
`
`appendix A HTTP syntax 309
`
`appendix B HTTP header-field definitions
`
`321
`
`glossary 370
`bibliography 372
`index 373
`
`008
`
`008
`
`