Fixed insertion of frame header buffer at the right index.

In case the lease is not empty, the frame header buffer must not be
inserted at index 0, but just before the frame body buffer.
This commit is contained in:
Simone Bordet 2014-08-04 12:15:14 +02:00
parent 1c984e680f
commit 20925ded97
3 changed files with 5 additions and 5 deletions

View File

@ -39,7 +39,6 @@ import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Jetty;
import org.eclipse.jetty.util.Promise;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
public class HTTP2Test extends AbstractTest
@ -128,7 +127,6 @@ public class HTTP2Test extends AbstractTest
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
}
@Ignore
@Test
public void testMultipleRequests() throws Exception
{

View File

@ -55,6 +55,7 @@ public class HeadersGenerator extends FrameGenerator
// The lease may already contain other buffers,
// compute the bytes generated by the encoder only.
int leaseSize = lease.getSize();
long leaseLength = lease.getTotalLength();
encoder.encode(metaData, lease, maxFrameSize);
long headersLength = lease.getTotalLength() - leaseLength;
@ -65,9 +66,9 @@ public class HeadersGenerator extends FrameGenerator
if (!contentFollows)
flags |= Flags.END_STREAM;
ByteBuffer header = generateHeader(lease, FrameType.HEADERS, (int)leaseLength, flags, streamId);
ByteBuffer header = generateHeader(lease, FrameType.HEADERS, (int)headersLength, flags, streamId);
BufferUtil.flipToFlush(header, 0);
lease.prepend(header, true);
lease.insert(leaseSize, header, true);
}
}

View File

@ -60,6 +60,7 @@ public class PushPromiseGenerator extends FrameGenerator
// The lease may already contain other buffers,
// compute the bytes generated by the encoder only.
int leaseSize = lease.getSize();
long leaseLength = lease.getTotalLength();
encoder.encode(metaData, lease, maxFrameSize);
long headersLength = lease.getTotalLength() - leaseLength;
@ -75,6 +76,6 @@ public class PushPromiseGenerator extends FrameGenerator
header.putInt(promisedStreamId);
BufferUtil.flipToFlush(header, 0);
lease.prepend(header, true);
lease.insert(leaseSize, header, true);
}
}