Skip to content

Commit 664a50b

Browse files
author
Stephane Landelle
committed
Clean up getAndSetWriteHeaders, that's actually 100-Continue related
1 parent 309af09 commit 664a50b

File tree

4 files changed

+12
-26
lines changed

4 files changed

+12
-26
lines changed

api/src/main/java/org/asynchttpclient/ListenableFuture.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,6 @@ public interface ListenableFuture<V> extends Future<V> {
5959
*/
6060
void touch();
6161

62-
/**
63-
* Write the {@link Request} headers
64-
*/
65-
boolean getAndSetWriteHeaders(boolean writeHeader);
66-
67-
/**
68-
* Write the {@link Request} body
69-
*/
70-
boolean getAndSetWriteBody(boolean writeBody);
71-
7262
/**
7363
* <p>Adds a listener and executor to the ListenableFuture.
7464
* The listener will be {@linkplain java.util.concurrent.Executor#execute(Runnable) passed

providers/netty/src/main/java/org/asynchttpclient/providers/netty/future/NettyResponseFuture.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public enum STATE {
9595
private HttpResponse pendingResponse;
9696
private boolean streamWasAlreadyConsumed;
9797
private boolean reuseChannel;
98-
private boolean writeHeaders;
98+
private boolean headersAlreadyWrittenOnContinue;
9999
private boolean writeBody;
100100
private boolean allowConnect;
101101

@@ -121,7 +121,6 @@ public NettyResponseFuture(URI uri,//
121121
} else {
122122
maxRetry = config.getMaxRequestRetry();
123123
}
124-
writeHeaders = true;
125124
writeBody = true;
126125
}
127126

@@ -419,19 +418,19 @@ public void setStreamWasAlreadyConsumed(boolean streamWasAlreadyConsumed) {
419418
public void touch() {
420419
touch.set(millisTime());
421420
}
422-
421+
423422
public long getLastTouch() {
424423
return touch.get();
425424
}
426425

427-
@Override
428-
public boolean getAndSetWriteHeaders(boolean writeHeaders) {
429-
boolean b = this.writeHeaders;
430-
this.writeHeaders = writeHeaders;
431-
return b;
426+
public void setHeadersAlreadyWrittenOnContinue(boolean headersAlreadyWrittenOnContinue) {
427+
this.headersAlreadyWrittenOnContinue = headersAlreadyWrittenOnContinue;
428+
}
429+
430+
public boolean isHeadersAlreadyWrittenOnContinue() {
431+
return headersAlreadyWrittenOnContinue;
432432
}
433433

434-
@Override
435434
public boolean getAndSetWriteBody(boolean writeBody) {
436435
boolean b = this.writeBody;
437436
this.writeBody = writeBody;

providers/netty/src/main/java/org/asynchttpclient/providers/netty/handler/HttpProtocol.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public void call() throws Exception {
245245

246246
private boolean handleContinueAndExit(final ChannelHandlerContext ctx, final NettyResponseFuture<?> future, int statusCode) {
247247
if (statusCode == CONTINUE.code()) {
248-
future.getAndSetWriteHeaders(false);
248+
future.setHeadersAlreadyWrittenOnContinue(true);;
249249
future.getAndSetWriteBody(true);
250250
// FIXME why not reuse the channel?
251251
requestSender.writeRequest(ctx.channel(), config, future);

providers/netty/src/main/java/org/asynchttpclient/providers/netty/request/NettyRequestSender.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,8 @@ private void scheduleTimeouts(NettyResponseFuture<?> nettyResponseFuture) {
328328

329329
public final <T> void writeRequest(final Channel channel, final AsyncHttpClientConfig config, final NettyResponseFuture<T> future) {
330330
try {
331-
// If the channel is dead because it was pooled and the remote
332-
// server decided to close it, we just let it go and the
333-
// closeChannel do it's work.
331+
// if the channel is dead because it was pooled and the remote server decided to close it,
332+
// we just let it go and the channelInactive do its work
334333
if (!channel.isOpen() || !channel.isActive()) {
335334
return;
336335
}
@@ -343,9 +342,7 @@ public final <T> void writeRequest(final Channel channel, final AsyncHttpClientC
343342
configureTransferAdapter(handler, httpRequest);
344343
}
345344

346-
// Leave it to true.
347-
// FIXME That doesn't just leave to true, the set is always done? and what's the point of not having a is/get?
348-
if (future.getAndSetWriteHeaders(true)) {
345+
if (!future.isHeadersAlreadyWrittenOnContinue()) {
349346
try {
350347
if (future.getAsyncHandler() instanceof AsyncHandlerExtensions) {
351348
AsyncHandlerExtensions.class.cast(future.getAsyncHandler()).onRequestSent();

0 commit comments

Comments
 (0)