Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Tài liệu Web Client Programming with Perl-Chapter 3: Learning HTTP- P1 pdf
Nội dung xem thử
Mô tả chi tiết
Chapter 3: Learning HTTP- P1
In the previous chapter, we went through a few examples of HTTP
transactions and outlined the structure that all HTTP follows. For the most
part, all web software will use an exchange similar to the HTTP we showed
you in Chapter 2, Demystifying the Browser. But now it's time to teach you
more about HTTP. Chapter 2 was like the "Spanish for Travelers"
phrasebook that you got for your trip to Madrid; this chapter is the textbook
for Spanish 101, required reading if you want course credit.
HTTP is defined by the HTTP specification, distributed by the World Wide
Web Consortium (W3C) at www.w3.org. If you are writing commercialquality HTTP applications, you should go directly to the spec, since it
defines which features need to be supported for HTTP compliance.
However, reading the spec is a tedious and often unpleasant experience, and
readers of this book are assumed to be more casual writers of HTTP clients,
so we've pared it down a bit to make HTTP more accessible for the specwary. This chapter includes:
Review of the structure of HTTP transactions. This section also serves
as a sort of road map to the rest of the chapter.
Discussion of the request methods clients may use. Beyond GET,
HEAD, and POST, we also give examples of the PUT, DELETE,
TRACE, and OPTIONS methods.
Summary of differences between various versions of HTTP. Clients
and servers must declare which version of HTTP they use. For the
most part, what you'll see is HTTP 1.0, but at least you'll know what
that means. We also cover HTTP 1.1, the newest version of HTTP to
date.
Listing of server response codes, and discussion of the more common
codes. These codes are the first indication of what to do with the
server's response (if any), so robust client programs should be
prepared to intercept them and interpret them properly.
Coverage of HTTP headers for both clients and servers. Headers give
clients the opportunity to declare who they are and what they want,
and they give servers the chance to tell clients what to expect.
This is one of the longest chapters in this book, and no doubt you won't read
it all in one sitting. Furthermore, if you use LWP, then you can go pretty far
without knowing more than a superficial amount of HTTP. But it's all
information you should know, so we recommend that you keep coming back
to it. Although a few key phrases will help you get around town, fluency
becomes very useful when you find yourself lost in the outskirts of the city.
Structure of an HTTP Transaction
All HTTP transactions follow the same general format, as shown in Figure
3-1.