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 package org.apache.hc.core5.http.nio.entity;
28
29 import java.io.IOException;
30 import java.nio.ByteBuffer;
31 import java.util.List;
32
33 import org.apache.hc.core5.concurrent.FutureCallback;
34 import org.apache.hc.core5.http.EntityDetails;
35 import org.apache.hc.core5.http.Header;
36 import org.apache.hc.core5.http.HttpException;
37 import org.apache.hc.core5.http.nio.AsyncEntityConsumer;
38 import org.apache.hc.core5.http.nio.CapacityChannel;
39
40
41
42
43
44
45 public final class DiscardingEntityConsumer<T> implements AsyncEntityConsumer<T> {
46
47 private volatile FutureCallback<T> resultCallback;
48
49 @Override
50 public void streamStart(
51 final EntityDetails entityDetails,
52 final FutureCallback<T> resultCallback) throws IOException, HttpException {
53 this.resultCallback = resultCallback;
54 }
55
56 @Override
57 public void updateCapacity(final CapacityChannel capacityChannel) throws IOException {
58 capacityChannel.update(Integer.MAX_VALUE);
59 }
60
61 @Override
62 public void consume(final ByteBuffer src) throws IOException {
63 }
64
65 @Override
66 public void streamEnd(final List<? extends Header> trailers) throws IOException {
67 if (resultCallback != null) {
68 resultCallback.completed(null);
69 }
70 }
71
72 @Override
73 public void failed(final Exception cause) {
74 if (resultCallback != null) {
75 resultCallback.failed(cause);
76 }
77 }
78
79 @Override
80 public T getContent() {
81 return null;
82 }
83
84 @Override
85 public void releaseResources() {
86 }
87
88 }