23
23
import org .asynchttpclient .request .body .Body ;
24
24
25
25
public final class SimpleFeedableBodyGenerator implements FeedableBodyGenerator , BodyGenerator {
26
- private final Queue <BodyPart > queue = new ConcurrentLinkedQueue <>();
26
+ private final Queue <BodyChunk > queue = new ConcurrentLinkedQueue <>();
27
27
private FeedListener listener ;
28
28
29
29
@ Override
@@ -33,7 +33,7 @@ public Body createBody() {
33
33
34
34
@ Override
35
35
public void feed (final ByteBuffer buffer , final boolean isLast ) {
36
- queue .offer (new BodyPart (buffer , isLast ));
36
+ queue .offer (new BodyChunk (buffer , isLast ));
37
37
if (listener != null ) {
38
38
listener .onContentAdded ();
39
39
}
@@ -57,18 +57,18 @@ public long getContentLength() {
57
57
public BodyState transferTo (final ByteBuf target ) throws IOException {
58
58
switch (state ) {
59
59
case CONTINUE :
60
- return readNextPart (target );
60
+ return readNextChunk (target );
61
61
case STOP :
62
62
return BodyState .STOP ;
63
63
default :
64
64
throw new IllegalStateException ("Illegal process state." );
65
65
}
66
66
}
67
67
68
- private BodyState readNextPart (ByteBuf target ) throws IOException {
68
+ private BodyState readNextChunk (ByteBuf target ) throws IOException {
69
69
BodyState res = BodyState .SUSPEND ;
70
70
while (target .isWritable () && state != BodyState .STOP ) {
71
- BodyPart nextPart = queue .peek ();
71
+ BodyChunk nextPart = queue .peek ();
72
72
if (nextPart == null ) {
73
73
// Nothing in the queue. suspend stream if nothing was read. (reads == 0)
74
74
return res ;
@@ -77,13 +77,13 @@ private BodyState readNextPart(ByteBuf target) throws IOException {
77
77
queue .remove ();
78
78
} else {
79
79
res = BodyState .CONTINUE ;
80
- readBodyPart (target , nextPart );
80
+ readBodyChunk (target , nextPart );
81
81
}
82
82
}
83
83
return res ;
84
84
}
85
85
86
- private void readBodyPart (ByteBuf target , BodyPart part ) {
86
+ private void readBodyChunk (ByteBuf target , BodyChunk part ) {
87
87
move (target , part .buffer );
88
88
89
89
if (!part .buffer .hasRemaining ()) {
@@ -109,11 +109,11 @@ private void move(ByteBuf target, ByteBuffer source) {
109
109
}
110
110
}
111
111
112
- private final class BodyPart {
112
+ private final class BodyChunk {
113
113
private final boolean isLast ;
114
114
private final ByteBuffer buffer ;
115
115
116
- public BodyPart (final ByteBuffer buffer , final boolean isLast ) {
116
+ public BodyChunk (final ByteBuffer buffer , final boolean isLast ) {
117
117
this .buffer = buffer ;
118
118
this .isLast = isLast ;
119
119
}
0 commit comments