Web Client Programming with Perl-Chapter 5: The LWP Library- P2

Tham khảo tài liệu 'web client programming with perl-chapter 5: the lwp library- p2', công nghệ thông tin, quản trị web phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 5 The LWP Library- P2 HTTP Response Responses from a web server are described by HTTP Response objects. If LWP has problems fulfilling your request it internally generates an HTTP Response object and fills in an appropriate response code. In the context of web client programming you ll usually get an HTTP Response object from LWP UserAgent and LWP RobotUA. If you plan to write extensions to LWP or a web server or proxy server you might use HTTP Response to generate your own responses. r new HTTP Response rc msg header content In its simplest form an HTTP Response object can contain just a response code. If you would like to specify a more detailed message than OK or Not found you can specify a human-readable description of the response code as the second parameter. As a third parameter you can pass a reference to an HTTP Headers object to specify the response headers. Finally you can also include an entitybody in the fourth parameter as a scalar. r- code code When invoked without any parameters the code method returns the object s response code. When invoked with a status code as the first parameter code defines the object s response to that value. r- is_info Returns true when the response code is 100 through 199. r- is_success Returns true when the response code is 200 through 299. r- is_redirect Returns true when the response code is 300 through 399. r- is_error Returns true when the response code is 400 through 599. When an error occurs you might want to use error_as_HTML to generate an HTML explanation of the error. r- message message Not to be confused with the entity-body of the response. This is the human-readable text that a user would usually see in the first line of an HTTP response from a server. With a response code of 200 RC_OK a common response would be a message of OK or Document follows. When invoked without any parameters the message method returns the object s HTTP message. When invoked with a scalar parameter as the first parameter .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
6    41    2    22-10-2021
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.