1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package org.apache.hc.client5.http.impl.classic;
29
30 import java.io.IOException;
31
32 import org.apache.hc.client5.http.classic.ExecChain;
33 import org.apache.hc.client5.http.classic.ExecChainHandler;
34 import org.apache.hc.core5.http.ClassicHttpRequest;
35 import org.apache.hc.core5.http.ClassicHttpResponse;
36 import org.apache.hc.core5.http.HttpException;
37
38 class ExecChainElement {
39
40 private final ExecChainHandler handler;
41 private final ExecChainElement next;
42
43 ExecChainElementement(final ExecChainHandler handler, final ExecChainElement next) {
44 this.handler = handler;
45 this.next = next;
46 }
47
48 public ClassicHttpResponse execute(
49 final ClassicHttpRequest request,
50 final ExecChain.Scope scope) throws IOException, HttpException {
51 return handler.execute(request, scope, new ExecChain() {
52
53 @Override
54 public ClassicHttpResponse proceed(
55 final ClassicHttpRequest request,
56 final Scope scope) throws IOException, HttpException {
57 return next.execute(request, scope);
58 }
59
60 });
61 }
62
63 @Override
64 public String toString() {
65 return "{" +
66 "handler=" + handler.getClass() +
67 ", next=" + (next != null ? next.handler.getClass() : "null") +
68 '}';
69 }
70 }