ii
Preface .................................................................................................................................... iv
1. HttpClient scope .......................................................................................................... iv
2. What HttpClient is NOT .............................................................................................. iv
1. Fundamentals ....................................................................................................................... 1
1.1. Request execution ...................................................................................................... 1
1.1.1. HTTP request .................................................................................................. 1
1.1.2. HTTP response ............................................................................................... 2
1.1.3. Working with message headers ........................................................................ 2
1.1.4. HTTP entity .................................................................................................... 3
1.1.5. Ensuring release of low level resources ............................................................ 5
1.1.6. Consuming entity content ................................................................................ 6
1.1.7. Producing entity content .................................................................................. 6
1.1.8. Response handlers ........................................................................................... 7
1.2. HttpClient interface .................................................................................................... 8
1.2.1. HttpClient thread safety ................................................................................... 8
1.2.2. HttpClient resource deallocation ...................................................................... 9
1.3. HTTP execution context ............................................................................................. 9
1.4. HTTP protocol interceptors ...................................................................................... 10
1.5. Exception handling ................................................................................................... 11
1.5.1. HTTP transport safety ................................................................................... 11
1.5.2. Idempotent methods ...................................................................................... 12
1.5.3. Automatic exception recovery ........................................................................ 12
1.5.4. Request retry handler ..................................................................................... 12
1.6. Aborting requests ..................................................................................................... 13
1.7. Redirect handling ..................................................................................................... 13
2. Connection management ..................................................................................................... 15
2.1. Connection persistence ............................................................................................. 15
2.2. HTTP connection routing ......................................................................................... 15
2.2.1. Route computation ........................................................................................ 15
2.2.2. Secure HTTP connections .............................................................................. 15
2.3. HTTP connection managers ...................................................................................... 16
2.3.1. Managed connections and connection managers .............................................. 16
2.3.2. Simple connection manager ........................................................................... 16
2.3.3. Pooling connection manager .......................................................................... 17
2.3.4. Connection manager shutdown ....................................................................... 17
2.4. Multithreaded request execution ................................................................................ 17
2.5. Connection eviction policy ....................................................................................... 19
2.6. Connection keep alive strategy ................................................................................. 20
2.7. Connection socket factories ...................................................................................... 20
2.7.1. Secure socket layering ................................................................................... 21
2.7.2. Integration with connection manager .............................................................. 21
2.7.3. SSL/TLS customization ................................................................................. 21
2.7.4. Hostname verification .................................................................................... 21
2.8. HttpClient proxy configuration ................................................................................. 22
3. HTTP state management ..................................................................................................... 24
3.1. HTTP cookies .......................................................................................................... 24
3.2. Cookie specifications ............................................................................................... 24
3.3. Choosing cookie policy ............................................................................................ 25
3.4. Custom cookie policy ............................................................................................... 26