392237 Improved handling of SPDY async send
This commit is contained in:
parent
7317dde852
commit
b5c6555a4a
|
@ -70,7 +70,16 @@ public class HttpTransportOverSPDY implements HttpTransport
|
|||
@Override
|
||||
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)
|
||||
{
|
||||
|
@ -108,11 +117,20 @@ public class HttpTransportOverSPDY implements HttpTransport
|
|||
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);
|
||||
}
|
||||
else if (lastContent)
|
||||
{
|
||||
stream.data(new ByteBufferDataInfo(BufferUtil.EMPTY_BUFFER, lastContent),endPoint.getIdleTimeout(),TimeUnit.MILLISECONDS,context,callback);
|
||||
}
|
||||
else
|
||||
callback.completed(context);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -74,7 +74,7 @@ public class NextProtoNegoServerConnection extends AbstractConnection implements
|
|||
if (nextProtocol == null && engine.getHandshakeStatus() == SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING)
|
||||
{
|
||||
// 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);
|
||||
close();
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
|
||||
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>
|
||||
*
|
||||
|
@ -72,7 +74,7 @@ public interface Callback<C>
|
|||
@Override
|
||||
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