392237 Improved handling of SPDY async send
This commit is contained in:
parent
7317dde852
commit
b5c6555a4a
|
@ -69,8 +69,17 @@ public class HttpTransportOverSPDY implements HttpTransport
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <C> void send(HttpGenerator.ResponseInfo info, ByteBuffer content, boolean lastContent, C context, Callback<C> callback)
|
public <C> void send(HttpGenerator.ResponseInfo info, ByteBuffer content, boolean lastContent, C context, Callback<C> callback)
|
||||||
{
|
{
|
||||||
boolean hasContent = !BufferUtil.isEmpty(content);
|
// info==null content==null lastContent==false should not happen
|
||||||
|
// info==null content==null lastContent==true signals no more content - complete
|
||||||
|
// info==null content!=null lastContent==false send data on committed response
|
||||||
|
// info==null content!=null lastContent==true send last data on committed response - complete
|
||||||
|
// info!=null content==null lastContent==false commit
|
||||||
|
// info!=null content==null lastContent==true commit and complete
|
||||||
|
// info!=null content!=null lastContent==false commit with content
|
||||||
|
// info!=null content!=null lastContent==true commit with content and complete
|
||||||
|
|
||||||
|
boolean hasContent = BufferUtil.hasContent(content);
|
||||||
|
|
||||||
if (info!=null)
|
if (info!=null)
|
||||||
{
|
{
|
||||||
|
@ -107,12 +116,21 @@ public class HttpTransportOverSPDY implements HttpTransport
|
||||||
boolean close = !hasContent && lastContent;
|
boolean close = !hasContent && lastContent;
|
||||||
reply(stream, new ReplyInfo(headers, close));
|
reply(stream, new ReplyInfo(headers, close));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((hasContent || lastContent ) && !stream.isClosed() )
|
if (stream.isClosed())
|
||||||
|
{
|
||||||
|
callback.failed(context,new EofException());
|
||||||
|
}
|
||||||
|
else if (hasContent)
|
||||||
|
{
|
||||||
stream.data(new ByteBufferDataInfo(content, lastContent),endPoint.getIdleTimeout(),TimeUnit.MILLISECONDS,context,callback);
|
stream.data(new ByteBufferDataInfo(content, lastContent),endPoint.getIdleTimeout(),TimeUnit.MILLISECONDS,context,callback);
|
||||||
|
}
|
||||||
|
else if (lastContent)
|
||||||
|
{
|
||||||
|
stream.data(new ByteBufferDataInfo(BufferUtil.EMPTY_BUFFER, lastContent),endPoint.getIdleTimeout(),TimeUnit.MILLISECONDS,context,callback);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
callback.completed(context);
|
callback.completed(context);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class NextProtoNegoServerConnection extends AbstractConnection implements
|
||||||
if (nextProtocol == null && engine.getHandshakeStatus() == SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING)
|
if (nextProtocol == null && engine.getHandshakeStatus() == SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING)
|
||||||
{
|
{
|
||||||
// The client sent the NPN extension, but did not send the NextProtocol
|
// The client sent the NPN extension, but did not send the NextProtocol
|
||||||
// message with the chosen protocol so we need to force the default protocol
|
// message with the chosen protocol so we need to close
|
||||||
LOG.debug("{} missing next protocol", this);
|
LOG.debug("{} missing next protocol", this);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.util;
|
package org.eclipse.jetty.util;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.util.log.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>A callback abstraction that handles completed/failed events of asynchronous operations.</p>
|
* <p>A callback abstraction that handles completed/failed events of asynchronous operations.</p>
|
||||||
*
|
*
|
||||||
|
@ -72,7 +74,7 @@ public interface Callback<C>
|
||||||
@Override
|
@Override
|
||||||
public void failed(C context, Throwable x)
|
public void failed(C context, Throwable x)
|
||||||
{
|
{
|
||||||
throw new RuntimeException(x);
|
Log.getLogger(this.getClass()).warn(String.valueOf(context),x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue