bug 1128038 - h2 DAV methods set end_stream bit twice r=hurley

This commit is contained in:
Patrick McManus 2015-02-02 13:42:23 -05:00
parent e804d384aa
commit 92c38efcb0
3 changed files with 19 additions and 42 deletions

View File

@ -477,6 +477,11 @@ Http2Stream::GenerateOpen()
head->IsConnect(),
compressedData);
int64_t clVal = mSession->Compressor()->GetParsedContentLength();
if (clVal != -1) {
mRequestBodyLenRemaining = clVal;
}
// Determine whether to put the fin bit on the header frame or whether
// to wait for a data packet to put it on.
uint8_t firstFrameFlags = Http2Session::kFlag_PRIORITY;
@ -582,42 +587,6 @@ Http2Stream::GenerateOpen()
(11 + head->RequestURI().Length() +
mFlatHttpRequestHeaders.Length());
const char *beginBuffer = mFlatHttpRequestHeaders.BeginReading();
int32_t crlfIndex = mFlatHttpRequestHeaders.Find("\r\n");
while (true) {
int32_t startIndex = crlfIndex + 2;
crlfIndex = mFlatHttpRequestHeaders.Find("\r\n", false, startIndex);
if (crlfIndex == -1)
break;
int32_t colonIndex = mFlatHttpRequestHeaders.Find(":", false, startIndex,
crlfIndex - startIndex);
if (colonIndex == -1)
break;
nsDependentCSubstring name = Substring(beginBuffer + startIndex,
beginBuffer + colonIndex);
// all header names are lower case in spdy
ToLowerCase(name);
if (name.EqualsLiteral("content-length")) {
nsCString *val = new nsCString();
int32_t valueIndex = colonIndex + 1;
while (valueIndex < crlfIndex && beginBuffer[valueIndex] == ' ')
++valueIndex;
nsDependentCSubstring v = Substring(beginBuffer + valueIndex,
beginBuffer + crlfIndex);
val->Append(v);
int64_t len;
if (nsHttp::ParseInt64(val->get(), nullptr, &len))
mRequestBodyLenRemaining = len;
break;
}
}
mFlatHttpRequestHeaders.Truncate();
Telemetry::Accumulate(Telemetry::SPDY_SYN_RATIO, ratio);
return NS_OK;

View File

@ -479,7 +479,7 @@ function test_http2_huge_suspended() {
}
// Support for doing a POST
function do_post(content, chan, listener) {
function do_post(content, chan, listener, method) {
var stream = Cc["@mozilla.org/io/string-input-stream;1"]
.createInstance(Ci.nsIStringInputStream);
stream.data = content;
@ -487,7 +487,7 @@ function do_post(content, chan, listener) {
var uchan = chan.QueryInterface(Ci.nsIUploadChannel);
uchan.setUploadStream(stream, "text/plain", stream.available());
chan.requestMethod = "POST";
chan.requestMethod = method;
chan.asyncOpen(listener, null);
}
@ -496,14 +496,21 @@ function do_post(content, chan, listener) {
function test_http2_post() {
var chan = makeChan("https://localhost:" + serverPort + "/post");
var listener = new Http2PostListener(md5s[0]);
do_post(posts[0], chan, listener);
do_post(posts[0], chan, listener, "POST");
}
// Make sure we can do a simple PATCH
function test_http2_patch() {
var chan = makeChan("https://localhost:" + serverPort + "/patch");
var listener = new Http2PostListener(md5s[0]);
do_post(posts[0], chan, listener, "PATCH");
}
// Make sure we can do a POST that covers more than 2 frames
function test_http2_post_big() {
var chan = makeChan("https://localhost:" + serverPort + "/post");
var listener = new Http2PostListener(md5s[1]);
do_post(posts[1], chan, listener);
do_post(posts[1], chan, listener, "POST");
}
Cu.import("resource://testing-common/httpd.js");
@ -739,6 +746,7 @@ var tests = [ test_http2_post_big
, test_http2_big
, test_http2_huge_suspended
, test_http2_post
, test_http2_patch
, test_http2_pushapi_1
// These next two must always come in this order
, test_http2_h11required_stream

View File

@ -262,8 +262,8 @@ function handleRequest(req, res) {
return;
}
else if (u.pathname === "/post") {
if (req.method != "POST") {
else if (u.pathname === "/post" || u.pathname === "/patch") {
if (req.method != "POST" && req.method != "PATCH") {
res.writeHead(405);
res.end('Unexpected method: ' + req.method);
return;