"HttpClient4.5 Chinese Course" "Chapter I: Basics" 1.6 Termination request, 1.7 redirect Processing

Source: Internet
Author: User

1.6. Termination of the request
In some cases, the HTTP request will fail within the expected time due to a high load on the target server or a large number of simultaneous requests from the client. At this point, it is necessary to prematurely abort the request and unlock the lock in I/O execution. When HttpClient executes, the request can be aborted at any stage by calling the Httpurirequest#abort () method. This method is thread-safe and can be called from any thread. When an HTTP request is aborted, its execution thread--is blocked in the I/O operation--and guaranteed to be unlocked by throwing a interruptedioexception exception.


1.7. REDIRECT Processing
HttpClient automatically handles all types of redirects. Except those that are expressly forbidden by the HTTP specification, such as the need for

of the user intervention. Refer to the redirection of other (status Code 303) POST and PUT requests to get requests that meet the HTTP specification requirements. You can use a redirect policy to break the limit for automatic redirection of post methods (post auto redirection is imposed for HTTP specification).


During the execution of the request message, httpclient often needs to rewrite it. Each default http/1.0 and http/1.1 use a relative URI. Similarly, the original request needs to be redirected from one address to another multiple times. The final absolute HTTP address will be built by the original request and context. The function method Uriutils#resolve is used to construct the absolute URI that the final request forms. This method contains the previous identity from the redirect and the original request.


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced! If you want to reprint please declare: "Transfer from http://blog.csdn.net/u011179993"

"HttpClient4.5 Chinese Course" "Chapter I: Basics" 1.6 Termination request, 1.7 redirect Processing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.