Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: net/spdy/spdy_framer_test.cc

Issue 265763011: Land recent SPDY changes (through 66310528) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_framer.cc ('k') | net/spdy/spdy_protocol.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <iostream> 6 #include <iostream>
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 0x03, 'f', 'o', 'o', 1850 0x03, 'f', 'o', 'o',
1851 0x00, 0x00, 0x00, 0x03, 1851 0x00, 0x00, 0x00, 0x03,
1852 'f', 'o', 'o', 0x00, 1852 'f', 'o', 'o', 0x00,
1853 0x00, 0x00, 0x03, 'b', 1853 0x00, 0x00, 0x03, 'b',
1854 'a', 'r' 1854 'a', 'r'
1855 }; 1855 };
1856 const unsigned char kV4FrameData[] = { 1856 const unsigned char kV4FrameData[] = {
1857 0x00, 0x16, 0x01, 0x0c, // HEADERS: PRIORITY | END_HEADERS 1857 0x00, 0x16, 0x01, 0x0c, // HEADERS: PRIORITY | END_HEADERS
1858 0x00, 0x00, 0x00, 0x01, // Stream 1 1858 0x00, 0x00, 0x00, 0x01, // Stream 1
1859 0x00, 0x00, 0x00, 0x07, // Priority 7 1859 0x00, 0x00, 0x00, 0x07, // Priority 7
1860 0x40, 0x03, 0x62, 0x61, // @.ba 1860 0x00, 0x03, 0x62, 0x61, // @.ba
1861 0x72, 0x03, 0x66, 0x6f, // r.fo 1861 0x72, 0x03, 0x66, 0x6f, // r.fo
1862 0x6f, 0x40, 0x03, 0x66, // o@.f 1862 0x6f, 0x00, 0x03, 0x66, // o@.f
1863 0x6f, 0x6f, 0x03, 0x62, // oo.b 1863 0x6f, 0x6f, 0x03, 0x62, // oo.b
1864 0x61, 0x72, // ar 1864 0x61, 0x72, // ar
1865 }; 1865 };
1866 SpdySynStreamIR syn_stream(1); 1866 SpdySynStreamIR syn_stream(1);
1867 syn_stream.set_priority(framer.GetLowestPriority()); 1867 syn_stream.set_priority(framer.GetLowestPriority());
1868 syn_stream.SetHeader("bar", "foo"); 1868 syn_stream.SetHeader("bar", "foo");
1869 syn_stream.SetHeader("foo", "bar"); 1869 syn_stream.SetHeader("foo", "bar");
1870 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream)); 1870 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream));
1871 if (IsSpdy2()) { 1871 if (IsSpdy2()) {
1872 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); 1872 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 0x00, 0x03, 'f', 'o', 1905 0x00, 0x03, 'f', 'o',
1906 'o', 0x00, 0x00, 0x00, 1906 'o', 0x00, 0x00, 0x00,
1907 0x03, 'f', 'o', 'o', 1907 0x03, 'f', 'o', 'o',
1908 0x00, 0x00, 0x00, 0x03, 1908 0x00, 0x00, 0x00, 0x03,
1909 'b', 'a', 'r' 1909 'b', 'a', 'r'
1910 }; 1910 };
1911 const unsigned char kV4FrameData[] = { 1911 const unsigned char kV4FrameData[] = {
1912 0x00, 0x13, 0x01, 0x0d, // HEADERS: PRIORITY | FIN | END_HEADERS 1912 0x00, 0x13, 0x01, 0x0d, // HEADERS: PRIORITY | FIN | END_HEADERS
1913 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff 1913 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff
1914 0x00, 0x00, 0x00, 0x00, // Priority 0 1914 0x00, 0x00, 0x00, 0x00, // Priority 0
1915 0x40, 0x00, 0x03, 0x66, // @..f 1915 0x00, 0x00, 0x03, 0x66, // @..f
1916 0x6f, 0x6f, 0x40, 0x03, // oo@. 1916 0x6f, 0x6f, 0x00, 0x03, // oo@.
1917 0x66, 0x6f, 0x6f, 0x03, // foo. 1917 0x66, 0x6f, 0x6f, 0x03, // foo.
1918 0x62, 0x61, 0x72, // bar 1918 0x62, 0x61, 0x72, // bar
1919 }; 1919 };
1920 SpdySynStreamIR syn_stream(0x7fffffff); 1920 SpdySynStreamIR syn_stream(0x7fffffff);
1921 syn_stream.set_associated_to_stream_id(0x7fffffff); 1921 syn_stream.set_associated_to_stream_id(0x7fffffff);
1922 syn_stream.set_priority(framer.GetHighestPriority()); 1922 syn_stream.set_priority(framer.GetHighestPriority());
1923 syn_stream.set_fin(true); 1923 syn_stream.set_fin(true);
1924 syn_stream.SetHeader("", "foo"); 1924 syn_stream.SetHeader("", "foo");
1925 syn_stream.SetHeader("foo", "bar"); 1925 syn_stream.SetHeader("foo", "bar");
1926 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream)); 1926 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 'r', 0x00, 0x00, 0x00, 1962 'r', 0x00, 0x00, 0x00,
1963 0x03, 'f', 'o', 'o', 1963 0x03, 'f', 'o', 'o',
1964 0x00, 0x00, 0x00, 0x03, 1964 0x00, 0x00, 0x00, 0x03,
1965 'f', 'o', 'o', 0x00, 1965 'f', 'o', 'o', 0x00,
1966 0x00, 0x00, 0x00 1966 0x00, 0x00, 0x00
1967 }; 1967 };
1968 const unsigned char kV4FrameData[] = { 1968 const unsigned char kV4FrameData[] = {
1969 0x00, 0x13, 0x01, 0x0d, // HEADERS: PRIORITY | FIN | END_HEADERS 1969 0x00, 0x13, 0x01, 0x0d, // HEADERS: PRIORITY | FIN | END_HEADERS
1970 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff 1970 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff
1971 0x00, 0x00, 0x00, 0x01, // Priority 1 1971 0x00, 0x00, 0x00, 0x01, // Priority 1
1972 0x40, 0x03, 0x62, 0x61, // @.ba 1972 0x00, 0x03, 0x62, 0x61, // @.ba
1973 0x72, 0x03, 0x66, 0x6f, // r.fo 1973 0x72, 0x03, 0x66, 0x6f, // r.fo
1974 0x6f, 0x40, 0x03, 0x66, // o@.f 1974 0x6f, 0x00, 0x03, 0x66, // o@.f
1975 0x6f, 0x6f, 0x00, // oo. 1975 0x6f, 0x6f, 0x00, // oo.
1976 }; 1976 };
1977 SpdySynStreamIR syn_stream(0x7fffffff); 1977 SpdySynStreamIR syn_stream(0x7fffffff);
1978 syn_stream.set_associated_to_stream_id(0x7fffffff); 1978 syn_stream.set_associated_to_stream_id(0x7fffffff);
1979 syn_stream.set_priority(1); 1979 syn_stream.set_priority(1);
1980 syn_stream.set_fin(true); 1980 syn_stream.set_fin(true);
1981 syn_stream.SetHeader("bar", "foo"); 1981 syn_stream.SetHeader("bar", "foo");
1982 syn_stream.SetHeader("foo", ""); 1982 syn_stream.SetHeader("foo", "");
1983 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream)); 1983 scoped_ptr<SpdyFrame> frame(framer.SerializeSynStream(syn_stream));
1984 if (IsSpdy2()) { 1984 if (IsSpdy2()) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
2082 'b', 'a', 'r', 0x00, 2082 'b', 'a', 'r', 0x00,
2083 0x00, 0x00, 0x03, 'f', 2083 0x00, 0x00, 0x03, 'f',
2084 'o', 'o', 0x00, 0x00, 2084 'o', 'o', 0x00, 0x00,
2085 0x00, 0x03, 'f', 'o', 2085 0x00, 0x03, 'f', 'o',
2086 'o', 0x00, 0x00, 0x00, 2086 'o', 0x00, 0x00, 0x00,
2087 0x03, 'b', 'a', 'r' 2087 0x03, 'b', 'a', 'r'
2088 }; 2088 };
2089 const unsigned char kV4FrameData[] = { 2089 const unsigned char kV4FrameData[] = {
2090 0x00, 0x12, 0x01, 0x04, // HEADER: END_HEADERS 2090 0x00, 0x12, 0x01, 0x04, // HEADER: END_HEADERS
2091 0x00, 0x00, 0x00, 0x01, // Stream 1 2091 0x00, 0x00, 0x00, 0x01, // Stream 1
2092 0x40, 0x03, 0x62, 0x61, // @.ba 2092 0x00, 0x03, 0x62, 0x61, // @.ba
2093 0x72, 0x03, 0x66, 0x6f, // r.fo 2093 0x72, 0x03, 0x66, 0x6f, // r.fo
2094 0x6f, 0x40, 0x03, 0x66, // o@.f 2094 0x6f, 0x00, 0x03, 0x66, // o@.f
2095 0x6f, 0x6f, 0x03, 0x62, // oo.b 2095 0x6f, 0x6f, 0x03, 0x62, // oo.b
2096 0x61, 0x72, // ar 2096 0x61, 0x72, // ar
2097 }; 2097 };
2098 SpdySynReplyIR syn_reply(1); 2098 SpdySynReplyIR syn_reply(1);
2099 syn_reply.SetHeader("bar", "foo"); 2099 syn_reply.SetHeader("bar", "foo");
2100 syn_reply.SetHeader("foo", "bar"); 2100 syn_reply.SetHeader("foo", "bar");
2101 scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply)); 2101 scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply));
2102 if (IsSpdy2()) { 2102 if (IsSpdy2()) {
2103 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); 2103 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
2104 } else if (IsSpdy3()) { 2104 } else if (IsSpdy3()) {
(...skipping 27 matching lines...) Expand all
2132 0x00, 0x00, 0x00, 0x03, 2132 0x00, 0x00, 0x00, 0x03,
2133 'f', 'o', 'o', 0x00, 2133 'f', 'o', 'o', 0x00,
2134 0x00, 0x00, 0x03, 'f', 2134 0x00, 0x00, 0x03, 'f',
2135 'o', 'o', 0x00, 0x00, 2135 'o', 'o', 0x00, 0x00,
2136 0x00, 0x03, 'b', 'a', 2136 0x00, 0x03, 'b', 'a',
2137 'r' 2137 'r'
2138 }; 2138 };
2139 const unsigned char kV4FrameData[] = { 2139 const unsigned char kV4FrameData[] = {
2140 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS 2140 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS
2141 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff 2141 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff
2142 0x40, 0x00, 0x03, 0x66, // @..f 2142 0x00, 0x00, 0x03, 0x66, // @..f
2143 0x6f, 0x6f, 0x40, 0x03, // oo@. 2143 0x6f, 0x6f, 0x00, 0x03, // oo@.
2144 0x66, 0x6f, 0x6f, 0x03, // foo. 2144 0x66, 0x6f, 0x6f, 0x03, // foo.
2145 0x62, 0x61, 0x72, // bar 2145 0x62, 0x61, 0x72, // bar
2146 }; 2146 };
2147 SpdySynReplyIR syn_reply(0x7fffffff); 2147 SpdySynReplyIR syn_reply(0x7fffffff);
2148 syn_reply.set_fin(true); 2148 syn_reply.set_fin(true);
2149 syn_reply.SetHeader("", "foo"); 2149 syn_reply.SetHeader("", "foo");
2150 syn_reply.SetHeader("foo", "bar"); 2150 syn_reply.SetHeader("foo", "bar");
2151 scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply)); 2151 scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply));
2152 if (IsSpdy2()) { 2152 if (IsSpdy2()) {
2153 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); 2153 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
(...skipping 28 matching lines...) Expand all
2182 'b', 'a', 'r', 0x00, 2182 'b', 'a', 'r', 0x00,
2183 0x00, 0x00, 0x03, 'f', 2183 0x00, 0x00, 0x03, 'f',
2184 'o', 'o', 0x00, 0x00, 2184 'o', 'o', 0x00, 0x00,
2185 0x00, 0x03, 'f', 'o', 2185 0x00, 0x03, 'f', 'o',
2186 'o', 0x00, 0x00, 0x00, 2186 'o', 0x00, 0x00, 0x00,
2187 0x00 2187 0x00
2188 }; 2188 };
2189 const unsigned char kV4FrameData[] = { 2189 const unsigned char kV4FrameData[] = {
2190 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS 2190 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS
2191 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff 2191 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff
2192 0x40, 0x03, 0x62, 0x61, // @.ba 2192 0x00, 0x03, 0x62, 0x61, // @.ba
2193 0x72, 0x03, 0x66, 0x6f, // r.fo 2193 0x72, 0x03, 0x66, 0x6f, // r.fo
2194 0x6f, 0x40, 0x03, 0x66, // o@.f 2194 0x6f, 0x00, 0x03, 0x66, // o@.f
2195 0x6f, 0x6f, 0x00, // oo. 2195 0x6f, 0x6f, 0x00, // oo.
2196 }; 2196 };
2197 SpdySynReplyIR syn_reply(0x7fffffff); 2197 SpdySynReplyIR syn_reply(0x7fffffff);
2198 syn_reply.set_fin(true); 2198 syn_reply.set_fin(true);
2199 syn_reply.SetHeader("bar", "foo"); 2199 syn_reply.SetHeader("bar", "foo");
2200 syn_reply.SetHeader("foo", ""); 2200 syn_reply.SetHeader("foo", "");
2201 scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply)); 2201 scoped_ptr<SpdyFrame> frame(framer.SerializeSynReply(syn_reply));
2202 if (IsSpdy2()) { 2202 if (IsSpdy2()) {
2203 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); 2203 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
2204 } else if (IsSpdy3()) { 2204 } else if (IsSpdy3()) {
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
2626 'b', 'a', 'r', 0x00, 2626 'b', 'a', 'r', 0x00,
2627 0x00, 0x00, 0x03, 'f', 2627 0x00, 0x00, 0x03, 'f',
2628 'o', 'o', 0x00, 0x00, 2628 'o', 'o', 0x00, 0x00,
2629 0x00, 0x03, 'f', 'o', 2629 0x00, 0x03, 'f', 'o',
2630 'o', 0x00, 0x00, 0x00, 2630 'o', 0x00, 0x00, 0x00,
2631 0x03, 'b', 'a', 'r' 2631 0x03, 'b', 'a', 'r'
2632 }; 2632 };
2633 const unsigned char kV4FrameData[] = { 2633 const unsigned char kV4FrameData[] = {
2634 0x00, 0x12, 0x01, 0x04, // Headers: END_HEADERS 2634 0x00, 0x12, 0x01, 0x04, // Headers: END_HEADERS
2635 0x00, 0x00, 0x00, 0x01, // Stream 1 2635 0x00, 0x00, 0x00, 0x01, // Stream 1
2636 0x40, 0x03, 0x62, 0x61, // @.ba 2636 0x00, 0x03, 0x62, 0x61, // @.ba
2637 0x72, 0x03, 0x66, 0x6f, // r.fo 2637 0x72, 0x03, 0x66, 0x6f, // r.fo
2638 0x6f, 0x40, 0x03, 0x66, // o@.f 2638 0x6f, 0x00, 0x03, 0x66, // o@.f
2639 0x6f, 0x6f, 0x03, 0x62, // oo.b 2639 0x6f, 0x6f, 0x03, 0x62, // oo.b
2640 0x61, 0x72, // ar 2640 0x61, 0x72, // ar
2641 }; 2641 };
2642 SpdyHeadersIR headers_ir(1); 2642 SpdyHeadersIR headers_ir(1);
2643 headers_ir.SetHeader("bar", "foo"); 2643 headers_ir.SetHeader("bar", "foo");
2644 headers_ir.SetHeader("foo", "bar"); 2644 headers_ir.SetHeader("foo", "bar");
2645 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir)); 2645 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir));
2646 if (IsSpdy2()) { 2646 if (IsSpdy2()) {
2647 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); 2647 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
2648 } else if (IsSpdy3()) { 2648 } else if (IsSpdy3()) {
(...skipping 27 matching lines...) Expand all
2676 0x00, 0x00, 0x00, 0x03, 2676 0x00, 0x00, 0x00, 0x03,
2677 'f', 'o', 'o', 0x00, 2677 'f', 'o', 'o', 0x00,
2678 0x00, 0x00, 0x03, 'f', 2678 0x00, 0x00, 0x03, 'f',
2679 'o', 'o', 0x00, 0x00, 2679 'o', 'o', 0x00, 0x00,
2680 0x00, 0x03, 'b', 'a', 2680 0x00, 0x03, 'b', 'a',
2681 'r' 2681 'r'
2682 }; 2682 };
2683 const unsigned char kV4FrameData[] = { 2683 const unsigned char kV4FrameData[] = {
2684 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS 2684 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS
2685 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff 2685 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff
2686 0x40, 0x00, 0x03, 0x66, // @..f 2686 0x00, 0x00, 0x03, 0x66, // @..f
2687 0x6f, 0x6f, 0x40, 0x03, // oo@. 2687 0x6f, 0x6f, 0x00, 0x03, // oo@.
2688 0x66, 0x6f, 0x6f, 0x03, // foo. 2688 0x66, 0x6f, 0x6f, 0x03, // foo.
2689 0x62, 0x61, 0x72, // bar 2689 0x62, 0x61, 0x72, // bar
2690 }; 2690 };
2691 SpdyHeadersIR headers_ir(0x7fffffff); 2691 SpdyHeadersIR headers_ir(0x7fffffff);
2692 headers_ir.set_fin(true); 2692 headers_ir.set_fin(true);
2693 headers_ir.SetHeader("", "foo"); 2693 headers_ir.SetHeader("", "foo");
2694 headers_ir.SetHeader("foo", "bar"); 2694 headers_ir.SetHeader("foo", "bar");
2695 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir)); 2695 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir));
2696 if (IsSpdy2()) { 2696 if (IsSpdy2()) {
2697 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); 2697 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
(...skipping 28 matching lines...) Expand all
2726 'b', 'a', 'r', 0x00, 2726 'b', 'a', 'r', 0x00,
2727 0x00, 0x00, 0x03, 'f', 2727 0x00, 0x00, 0x03, 'f',
2728 'o', 'o', 0x00, 0x00, 2728 'o', 'o', 0x00, 0x00,
2729 0x00, 0x03, 'f', 'o', 2729 0x00, 0x03, 'f', 'o',
2730 'o', 0x00, 0x00, 0x00, 2730 'o', 0x00, 0x00, 0x00,
2731 0x00 2731 0x00
2732 }; 2732 };
2733 const unsigned char kV4FrameData[] = { 2733 const unsigned char kV4FrameData[] = {
2734 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS 2734 0x00, 0x0f, 0x01, 0x05, // HEADER: FIN | END_HEADERS
2735 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff 2735 0x7f, 0xff, 0xff, 0xff, // Stream 0x7fffffff
2736 0x40, 0x03, 0x62, 0x61, // @.ba 2736 0x00, 0x03, 0x62, 0x61, // @.ba
2737 0x72, 0x03, 0x66, 0x6f, // r.fo 2737 0x72, 0x03, 0x66, 0x6f, // r.fo
2738 0x6f, 0x40, 0x03, 0x66, // o@.f 2738 0x6f, 0x00, 0x03, 0x66, // o@.f
2739 0x6f, 0x6f, 0x00, // oo. 2739 0x6f, 0x6f, 0x00, // oo.
2740 }; 2740 };
2741 SpdyHeadersIR headers_ir(0x7fffffff); 2741 SpdyHeadersIR headers_ir(0x7fffffff);
2742 headers_ir.set_fin(true); 2742 headers_ir.set_fin(true);
2743 headers_ir.SetHeader("bar", "foo"); 2743 headers_ir.SetHeader("bar", "foo");
2744 headers_ir.SetHeader("foo", ""); 2744 headers_ir.SetHeader("foo", "");
2745 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir)); 2745 scoped_ptr<SpdyFrame> frame(framer.SerializeHeaders(headers_ir));
2746 if (IsSpdy2()) { 2746 if (IsSpdy2()) {
2747 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData)); 2747 CompareFrame(kDescription, *frame, kV2FrameData, arraysize(kV2FrameData));
2748 } else if (IsSpdy3()) { 2748 } else if (IsSpdy3()) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2924 } 2924 }
2925 2925
2926 SpdyFramer framer(spdy_version_); 2926 SpdyFramer framer(spdy_version_);
2927 framer.set_enable_compression(false); 2927 framer.set_enable_compression(false);
2928 const char kDescription[] = "PUSH_PROMISE frame"; 2928 const char kDescription[] = "PUSH_PROMISE frame";
2929 2929
2930 const unsigned char kFrameData[] = { 2930 const unsigned char kFrameData[] = {
2931 0x00, 0x16, 0x05, 0x04, // PUSH_PROMISE: END_HEADERS 2931 0x00, 0x16, 0x05, 0x04, // PUSH_PROMISE: END_HEADERS
2932 0x00, 0x00, 0x00, 0x2a, // Stream 42 2932 0x00, 0x00, 0x00, 0x2a, // Stream 42
2933 0x00, 0x00, 0x00, 0x39, // Promised stream 57 2933 0x00, 0x00, 0x00, 0x39, // Promised stream 57
2934 0x40, 0x03, 0x62, 0x61, // @.ba 2934 0x00, 0x03, 0x62, 0x61, // @.ba
2935 0x72, 0x03, 0x66, 0x6f, // r.fo 2935 0x72, 0x03, 0x66, 0x6f, // r.fo
2936 0x6f, 0x40, 0x03, 0x66, // o@.f 2936 0x6f, 0x00, 0x03, 0x66, // o@.f
2937 0x6f, 0x6f, 0x03, 0x62, // oo.b 2937 0x6f, 0x6f, 0x03, 0x62, // oo.b
2938 0x61, 0x72, // ar 2938 0x61, 0x72, // ar
2939 }; 2939 };
2940 2940
2941 SpdyPushPromiseIR push_promise(42, 57); 2941 SpdyPushPromiseIR push_promise(42, 57);
2942 push_promise.SetHeader("bar", "foo"); 2942 push_promise.SetHeader("bar", "foo");
2943 push_promise.SetHeader("foo", "bar"); 2943 push_promise.SetHeader("foo", "bar");
2944 scoped_ptr<SpdySerializedFrame> frame( 2944 scoped_ptr<SpdySerializedFrame> frame(
2945 framer.SerializePushPromise(push_promise)); 2945 framer.SerializePushPromise(push_promise));
2946 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); 2946 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData));
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
3666 return; 3666 return;
3667 } 3667 }
3668 3668
3669 SpdyFramer framer(spdy_version_); 3669 SpdyFramer framer(spdy_version_);
3670 framer.set_enable_compression(false); 3670 framer.set_enable_compression(false);
3671 const char kDescription[] = "CONTINUATION frame"; 3671 const char kDescription[] = "CONTINUATION frame";
3672 3672
3673 const unsigned char kFrameData[] = { 3673 const unsigned char kFrameData[] = {
3674 0x00, 0x12, 0x09, 0x00, // CONTINUATION 3674 0x00, 0x12, 0x09, 0x00, // CONTINUATION
3675 0x00, 0x00, 0x00, 0x2a, // Stream 42 3675 0x00, 0x00, 0x00, 0x2a, // Stream 42
3676 0x40, 0x03, 0x62, 0x61, // @.ba 3676 0x00, 0x03, 0x62, 0x61, // @.ba
3677 0x72, 0x03, 0x66, 0x6f, // r.fo 3677 0x72, 0x03, 0x66, 0x6f, // r.fo
3678 0x6f, 0x40, 0x03, 0x66, // o@.f 3678 0x6f, 0x00, 0x03, 0x66, // o@.f
3679 0x6f, 0x6f, 0x03, 0x62, // oo.b 3679 0x6f, 0x6f, 0x03, 0x62, // oo.b
3680 0x61, 0x72, // ar 3680 0x61, 0x72, // ar
3681 }; 3681 };
3682 3682
3683 SpdyContinuationIR continuation(42); 3683 SpdyContinuationIR continuation(42);
3684 continuation.SetHeader("bar", "foo"); 3684 continuation.SetHeader("bar", "foo");
3685 continuation.SetHeader("foo", "bar"); 3685 continuation.SetHeader("foo", "bar");
3686 scoped_ptr<SpdySerializedFrame> frame( 3686 scoped_ptr<SpdySerializedFrame> frame(
3687 framer.SerializeContinuation(continuation)); 3687 framer.SerializeContinuation(continuation));
3688 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); 3688 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData));
(...skipping 23 matching lines...) Expand all
3712 } 3712 }
3713 3713
3714 TEST_P(SpdyFramerTest, ReadHeadersWithContinuation) { 3714 TEST_P(SpdyFramerTest, ReadHeadersWithContinuation) {
3715 if (spdy_version_ <= SPDY3) { 3715 if (spdy_version_ <= SPDY3) {
3716 return; 3716 return;
3717 } 3717 }
3718 3718
3719 const unsigned char kInput[] = { 3719 const unsigned char kInput[] = {
3720 0x00, 0x10, 0x01, 0x00, // HEADERS 3720 0x00, 0x10, 0x01, 0x00, // HEADERS
3721 0x00, 0x00, 0x00, 0x01, // Stream 1 3721 0x00, 0x00, 0x00, 0x01, // Stream 1
3722 0x40, 0x06, 0x43, 0x6f, 3722 0x00, 0x06, 0x63, 0x6f,
3723 0x6f, 0x6b, 0x69, 0x65, 3723 0x6f, 0x6b, 0x69, 0x65,
3724 0x07, 0x66, 0x6f, 0x6f, 3724 0x07, 0x66, 0x6f, 0x6f,
3725 0x3d, 0x62, 0x61, 0x72, 3725 0x3d, 0x62, 0x61, 0x72,
3726 3726
3727 0x00, 0x14, 0x09, 0x00, // CONTINUATION 3727 0x00, 0x14, 0x09, 0x00, // CONTINUATION
3728 0x00, 0x00, 0x00, 0x01, // Stream 1 3728 0x00, 0x00, 0x00, 0x01, // Stream 1
3729 0x40, 0x06, 0x43, 0x6f, 3729 0x00, 0x06, 0x63, 0x6f,
3730 0x6f, 0x6b, 0x69, 0x65, 3730 0x6f, 0x6b, 0x69, 0x65,
3731 0x08, 0x62, 0x61, 0x7a, 3731 0x08, 0x62, 0x61, 0x7a,
3732 0x3d, 0x62, 0x69, 0x6e, 3732 0x3d, 0x62, 0x69, 0x6e,
3733 0x67, 0x40, 0x06, 0x43, 3733 0x67, 0x00, 0x06, 0x63,
3734 3734
3735 0x00, 0x12, 0x09, 0x04, // CONTINUATION: END_HEADERS 3735 0x00, 0x12, 0x09, 0x04, // CONTINUATION: END_HEADERS
3736 0x00, 0x00, 0x00, 0x01, // Stream 1 3736 0x00, 0x00, 0x00, 0x01, // Stream 1
3737 0x6f, 0x6f, 0x6b, 0x69, 3737 0x6f, 0x6f, 0x6b, 0x69,
3738 0x65, 0x00, 0x40, 0x04, 3738 0x65, 0x00, 0x00, 0x04,
3739 0x6e, 0x61, 0x6d, 0x65, 3739 0x6e, 0x61, 0x6d, 0x65,
3740 0x05, 0x76, 0x61, 0x6c, 3740 0x05, 0x76, 0x61, 0x6c,
3741 0x75, 0x65, 3741 0x75, 0x65,
3742 }; 3742 };
3743 3743
3744 SpdyFramer framer(spdy_version_); 3744 SpdyFramer framer(spdy_version_);
3745 TestSpdyVisitor visitor(spdy_version_); 3745 TestSpdyVisitor visitor(spdy_version_);
3746 visitor.SimulateInFramer(kInput, sizeof(kInput)); 3746 visitor.SimulateInFramer(kInput, sizeof(kInput));
3747 3747
3748 EXPECT_EQ(0, visitor.error_count_); 3748 EXPECT_EQ(0, visitor.error_count_);
3749 EXPECT_EQ(1, visitor.headers_frame_count_); 3749 EXPECT_EQ(1, visitor.headers_frame_count_);
3750 EXPECT_EQ(2, visitor.continuation_count_); 3750 EXPECT_EQ(2, visitor.continuation_count_);
3751 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); 3751 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_);
3752 EXPECT_EQ(0, visitor.zero_length_data_frame_count_); 3752 EXPECT_EQ(0, visitor.zero_length_data_frame_count_);
3753 3753
3754 EXPECT_THAT(visitor.headers_, ElementsAre( 3754 EXPECT_THAT(visitor.headers_, ElementsAre(
3755 Pair("Cookie", "foo=bar; baz=bing; "), 3755 Pair("cookie", "foo=bar; baz=bing; "),
3756 Pair("name", "value"))); 3756 Pair("name", "value")));
3757 } 3757 }
3758 3758
3759 TEST_P(SpdyFramerTest, ReadHeadersWithContinuationAndFin) { 3759 TEST_P(SpdyFramerTest, ReadHeadersWithContinuationAndFin) {
3760 if (spdy_version_ <= SPDY3) { 3760 if (spdy_version_ <= SPDY3) {
3761 return; 3761 return;
3762 } 3762 }
3763 3763
3764 const unsigned char kInput[] = { 3764 const unsigned char kInput[] = {
3765 0x00, 0x10, 0x01, 0x01, // HEADERS: FIN 3765 0x00, 0x10, 0x01, 0x01, // HEADERS: FIN
3766 0x00, 0x00, 0x00, 0x01, // Stream 1 3766 0x00, 0x00, 0x00, 0x01, // Stream 1
3767 0x40, 0x06, 0x43, 0x6f, 3767 0x00, 0x06, 0x63, 0x6f,
3768 0x6f, 0x6b, 0x69, 0x65, 3768 0x6f, 0x6b, 0x69, 0x65,
3769 0x07, 0x66, 0x6f, 0x6f, 3769 0x07, 0x66, 0x6f, 0x6f,
3770 0x3d, 0x62, 0x61, 0x72, 3770 0x3d, 0x62, 0x61, 0x72,
3771 3771
3772 0x00, 0x14, 0x09, 0x00, // CONTINUATION 3772 0x00, 0x14, 0x09, 0x00, // CONTINUATION
3773 0x00, 0x00, 0x00, 0x01, // Stream 1 3773 0x00, 0x00, 0x00, 0x01, // Stream 1
3774 0x40, 0x06, 0x43, 0x6f, 3774 0x00, 0x06, 0x63, 0x6f,
3775 0x6f, 0x6b, 0x69, 0x65, 3775 0x6f, 0x6b, 0x69, 0x65,
3776 0x08, 0x62, 0x61, 0x7a, 3776 0x08, 0x62, 0x61, 0x7a,
3777 0x3d, 0x62, 0x69, 0x6e, 3777 0x3d, 0x62, 0x69, 0x6e,
3778 0x67, 0x40, 0x06, 0x43, 3778 0x67, 0x00, 0x06, 0x63,
3779 3779
3780 0x00, 0x12, 0x09, 0x04, // CONTINUATION: END_HEADERS 3780 0x00, 0x12, 0x09, 0x04, // CONTINUATION: END_HEADERS
3781 0x00, 0x00, 0x00, 0x01, // Stream 1 3781 0x00, 0x00, 0x00, 0x01, // Stream 1
3782 0x6f, 0x6f, 0x6b, 0x69, 3782 0x6f, 0x6f, 0x6b, 0x69,
3783 0x65, 0x00, 0x40, 0x04, 3783 0x65, 0x00, 0x00, 0x04,
3784 0x6e, 0x61, 0x6d, 0x65, 3784 0x6e, 0x61, 0x6d, 0x65,
3785 0x05, 0x76, 0x61, 0x6c, 3785 0x05, 0x76, 0x61, 0x6c,
3786 0x75, 0x65, 3786 0x75, 0x65,
3787 }; 3787 };
3788 3788
3789 SpdyFramer framer(spdy_version_); 3789 SpdyFramer framer(spdy_version_);
3790 TestSpdyVisitor visitor(spdy_version_); 3790 TestSpdyVisitor visitor(spdy_version_);
3791 visitor.SimulateInFramer(kInput, sizeof(kInput)); 3791 visitor.SimulateInFramer(kInput, sizeof(kInput));
3792 3792
3793 EXPECT_EQ(0, visitor.error_count_); 3793 EXPECT_EQ(0, visitor.error_count_);
3794 EXPECT_EQ(1, visitor.headers_frame_count_); 3794 EXPECT_EQ(1, visitor.headers_frame_count_);
3795 EXPECT_EQ(2, visitor.continuation_count_); 3795 EXPECT_EQ(2, visitor.continuation_count_);
3796 EXPECT_EQ(1, visitor.fin_flag_count_); 3796 EXPECT_EQ(1, visitor.fin_flag_count_);
3797 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); 3797 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_);
3798 EXPECT_EQ(1, visitor.zero_length_data_frame_count_); 3798 EXPECT_EQ(1, visitor.zero_length_data_frame_count_);
3799 3799
3800 EXPECT_THAT(visitor.headers_, ElementsAre( 3800 EXPECT_THAT(visitor.headers_, ElementsAre(
3801 Pair("Cookie", "foo=bar; baz=bing; "), 3801 Pair("cookie", "foo=bar; baz=bing; "),
3802 Pair("name", "value"))); 3802 Pair("name", "value")));
3803 } 3803 }
3804 3804
3805 TEST_P(SpdyFramerTest, ReadPushPromiseWithContinuation) { 3805 TEST_P(SpdyFramerTest, ReadPushPromiseWithContinuation) {
3806 if (spdy_version_ <= SPDY3) { 3806 if (spdy_version_ <= SPDY3) {
3807 return; 3807 return;
3808 } 3808 }
3809 3809
3810 const unsigned char kInput[] = { 3810 const unsigned char kInput[] = {
3811 0x00, 0x14, 0x05, 0x00, // PUSH_PROMISE 3811 0x00, 0x14, 0x05, 0x00, // PUSH_PROMISE
3812 0x00, 0x00, 0x00, 0x01, // Stream 1 3812 0x00, 0x00, 0x00, 0x01, // Stream 1
3813 0x00, 0x00, 0x00, 0x2A, // Promised stream 42 3813 0x00, 0x00, 0x00, 0x2A, // Promised stream 42
3814 0x40, 0x06, 0x43, 0x6f, 3814 0x00, 0x06, 0x63, 0x6f,
3815 0x6f, 0x6b, 0x69, 0x65, 3815 0x6f, 0x6b, 0x69, 0x65,
3816 0x07, 0x66, 0x6f, 0x6f, 3816 0x07, 0x66, 0x6f, 0x6f,
3817 0x3d, 0x62, 0x61, 0x72, 3817 0x3d, 0x62, 0x61, 0x72,
3818 3818
3819 0x00, 0x14, 0x09, 0x00, // CONTINUATION 3819 0x00, 0x14, 0x09, 0x00, // CONTINUATION
3820 0x00, 0x00, 0x00, 0x01, // Stream 1 3820 0x00, 0x00, 0x00, 0x01, // Stream 1
3821 0x40, 0x06, 0x43, 0x6f, 3821 0x00, 0x06, 0x63, 0x6f,
3822 0x6f, 0x6b, 0x69, 0x65, 3822 0x6f, 0x6b, 0x69, 0x65,
3823 0x08, 0x62, 0x61, 0x7a, 3823 0x08, 0x62, 0x61, 0x7a,
3824 0x3d, 0x62, 0x69, 0x6e, 3824 0x3d, 0x62, 0x69, 0x6e,
3825 0x67, 0x40, 0x06, 0x43, 3825 0x67, 0x00, 0x06, 0x63,
3826 3826
3827 0x00, 0x12, 0x09, 0x04, // CONTINUATION: END_HEADERS 3827 0x00, 0x12, 0x09, 0x04, // CONTINUATION: END_HEADERS
3828 0x00, 0x00, 0x00, 0x01, // Stream 1 3828 0x00, 0x00, 0x00, 0x01, // Stream 1
3829 0x6f, 0x6f, 0x6b, 0x69, 3829 0x6f, 0x6f, 0x6b, 0x69,
3830 0x65, 0x00, 0x40, 0x04, 3830 0x65, 0x00, 0x00, 0x04,
3831 0x6e, 0x61, 0x6d, 0x65, 3831 0x6e, 0x61, 0x6d, 0x65,
3832 0x05, 0x76, 0x61, 0x6c, 3832 0x05, 0x76, 0x61, 0x6c,
3833 0x75, 0x65, 3833 0x75, 0x65,
3834 }; 3834 };
3835 3835
3836 SpdyFramer framer(spdy_version_); 3836 SpdyFramer framer(spdy_version_);
3837 TestSpdyVisitor visitor(spdy_version_); 3837 TestSpdyVisitor visitor(spdy_version_);
3838 visitor.SimulateInFramer(kInput, sizeof(kInput)); 3838 visitor.SimulateInFramer(kInput, sizeof(kInput));
3839 3839
3840 EXPECT_EQ(0, visitor.error_count_); 3840 EXPECT_EQ(0, visitor.error_count_);
3841 EXPECT_EQ(1u, visitor.last_push_promise_stream_); 3841 EXPECT_EQ(1u, visitor.last_push_promise_stream_);
3842 EXPECT_EQ(42u, visitor.last_push_promise_promised_stream_); 3842 EXPECT_EQ(42u, visitor.last_push_promise_promised_stream_);
3843 EXPECT_EQ(2, visitor.continuation_count_); 3843 EXPECT_EQ(2, visitor.continuation_count_);
3844 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); 3844 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_);
3845 EXPECT_EQ(0, visitor.zero_length_data_frame_count_); 3845 EXPECT_EQ(0, visitor.zero_length_data_frame_count_);
3846 3846
3847 EXPECT_THAT(visitor.headers_, ElementsAre( 3847 EXPECT_THAT(visitor.headers_, ElementsAre(
3848 Pair("Cookie", "foo=bar; baz=bing; "), 3848 Pair("cookie", "foo=bar; baz=bing; "),
3849 Pair("name", "value"))); 3849 Pair("name", "value")));
3850 } 3850 }
3851 3851
3852 TEST_P(SpdyFramerTest, ReadContinuationWithWrongStreamId) { 3852 TEST_P(SpdyFramerTest, ReadContinuationWithWrongStreamId) {
3853 if (spdy_version_ <= SPDY3) { 3853 if (spdy_version_ <= SPDY3) {
3854 return; 3854 return;
3855 } 3855 }
3856 3856
3857 const unsigned char kInput[] = { 3857 const unsigned char kInput[] = {
3858 0x00, 0x10, 0x01, 0x00, // HEADERS 3858 0x00, 0x10, 0x01, 0x00, // HEADERS
3859 0x00, 0x00, 0x00, 0x01, // Stream 1 3859 0x00, 0x00, 0x00, 0x01, // Stream 1
3860 0x40, 0x06, 0x43, 0x6f, 3860 0x00, 0x06, 0x63, 0x6f,
3861 0x6f, 0x6b, 0x69, 0x65, 3861 0x6f, 0x6b, 0x69, 0x65,
3862 0x07, 0x66, 0x6f, 0x6f, 3862 0x07, 0x66, 0x6f, 0x6f,
3863 0x3d, 0x62, 0x61, 0x72, 3863 0x3d, 0x62, 0x61, 0x72,
3864 3864
3865 0x00, 0x14, 0x09, 0x00, // CONTINUATION 3865 0x00, 0x14, 0x09, 0x00, // CONTINUATION
3866 0x00, 0x00, 0x00, 0x02, // Stream 2 3866 0x00, 0x00, 0x00, 0x02, // Stream 2
3867 0x40, 0x06, 0x43, 0x6f, 3867 0x00, 0x06, 0x63, 0x6f,
3868 0x6f, 0x6b, 0x69, 0x65, 3868 0x6f, 0x6b, 0x69, 0x65,
3869 0x08, 0x62, 0x61, 0x7a, 3869 0x08, 0x62, 0x61, 0x7a,
3870 0x3d, 0x62, 0x69, 0x6e, 3870 0x3d, 0x62, 0x69, 0x6e,
3871 0x67, 0x40, 0x06, 0x43, 3871 0x67, 0x00, 0x06, 0x63,
3872 }; 3872 };
3873 3873
3874 SpdyFramer framer(spdy_version_); 3874 SpdyFramer framer(spdy_version_);
3875 TestSpdyVisitor visitor(spdy_version_); 3875 TestSpdyVisitor visitor(spdy_version_);
3876 framer.set_visitor(&visitor); 3876 framer.set_visitor(&visitor);
3877 visitor.SimulateInFramer(kInput, sizeof(kInput)); 3877 visitor.SimulateInFramer(kInput, sizeof(kInput));
3878 3878
3879 EXPECT_EQ(1, visitor.error_count_); 3879 EXPECT_EQ(1, visitor.error_count_);
3880 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, 3880 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME,
3881 visitor.framer_.error_code()) 3881 visitor.framer_.error_code())
3882 << SpdyFramer::ErrorCodeToString(framer.error_code()); 3882 << SpdyFramer::ErrorCodeToString(framer.error_code());
3883 EXPECT_EQ(1, visitor.headers_frame_count_); 3883 EXPECT_EQ(1, visitor.headers_frame_count_);
3884 EXPECT_EQ(0, visitor.continuation_count_); 3884 EXPECT_EQ(0, visitor.continuation_count_);
3885 EXPECT_EQ(0u, visitor.header_buffer_length_); 3885 EXPECT_EQ(0u, visitor.header_buffer_length_);
3886 } 3886 }
3887 3887
3888 TEST_P(SpdyFramerTest, ReadContinuationOutOfOrder) { 3888 TEST_P(SpdyFramerTest, ReadContinuationOutOfOrder) {
3889 if (spdy_version_ <= SPDY3) { 3889 if (spdy_version_ <= SPDY3) {
3890 return; 3890 return;
3891 } 3891 }
3892 3892
3893 const unsigned char kInput[] = { 3893 const unsigned char kInput[] = {
3894 0x00, 0x10, 0x09, 0x00, // CONTINUATION 3894 0x00, 0x10, 0x09, 0x00, // CONTINUATION
3895 0x00, 0x00, 0x00, 0x01, // Stream 1 3895 0x00, 0x00, 0x00, 0x01, // Stream 1
3896 0x40, 0x06, 0x43, 0x6f, 3896 0x00, 0x06, 0x63, 0x6f,
3897 0x6f, 0x6b, 0x69, 0x65, 3897 0x6f, 0x6b, 0x69, 0x65,
3898 0x07, 0x66, 0x6f, 0x6f, 3898 0x07, 0x66, 0x6f, 0x6f,
3899 0x3d, 0x62, 0x61, 0x72, 3899 0x3d, 0x62, 0x61, 0x72,
3900 }; 3900 };
3901 3901
3902 SpdyFramer framer(spdy_version_); 3902 SpdyFramer framer(spdy_version_);
3903 TestSpdyVisitor visitor(spdy_version_); 3903 TestSpdyVisitor visitor(spdy_version_);
3904 framer.set_visitor(&visitor); 3904 framer.set_visitor(&visitor);
3905 visitor.SimulateInFramer(kInput, sizeof(kInput)); 3905 visitor.SimulateInFramer(kInput, sizeof(kInput));
3906 3906
3907 EXPECT_EQ(1, visitor.error_count_); 3907 EXPECT_EQ(1, visitor.error_count_);
3908 EXPECT_EQ(SpdyFramer::SPDY_UNEXPECTED_FRAME, 3908 EXPECT_EQ(SpdyFramer::SPDY_UNEXPECTED_FRAME,
3909 visitor.framer_.error_code()) 3909 visitor.framer_.error_code())
3910 << SpdyFramer::ErrorCodeToString(framer.error_code()); 3910 << SpdyFramer::ErrorCodeToString(framer.error_code());
3911 EXPECT_EQ(0, visitor.continuation_count_); 3911 EXPECT_EQ(0, visitor.continuation_count_);
3912 EXPECT_EQ(0u, visitor.header_buffer_length_); 3912 EXPECT_EQ(0u, visitor.header_buffer_length_);
3913 } 3913 }
3914 3914
3915 TEST_P(SpdyFramerTest, ExpectContinuationReceiveData) { 3915 TEST_P(SpdyFramerTest, ExpectContinuationReceiveData) {
3916 if (spdy_version_ <= SPDY3) { 3916 if (spdy_version_ <= SPDY3) {
3917 return; 3917 return;
3918 } 3918 }
3919 3919
3920 const unsigned char kInput[] = { 3920 const unsigned char kInput[] = {
3921 0x00, 0x10, 0x01, 0x00, // HEADERS 3921 0x00, 0x10, 0x01, 0x00, // HEADERS
3922 0x00, 0x00, 0x00, 0x01, // Stream 1 3922 0x00, 0x00, 0x00, 0x01, // Stream 1
3923 0x40, 0x06, 0x43, 0x6f, 3923 0x00, 0x06, 0x63, 0x6f,
3924 0x6f, 0x6b, 0x69, 0x65, 3924 0x6f, 0x6b, 0x69, 0x65,
3925 0x07, 0x66, 0x6f, 0x6f, 3925 0x07, 0x66, 0x6f, 0x6f,
3926 0x3d, 0x62, 0x61, 0x72, 3926 0x3d, 0x62, 0x61, 0x72,
3927 3927
3928 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1 3928 0x00, 0x00, 0x00, 0x01, // DATA on Stream #1
3929 0x00, 0x00, 0x00, 0x04, 3929 0x00, 0x00, 0x00, 0x04,
3930 0xde, 0xad, 0xbe, 0xef, 3930 0xde, 0xad, 0xbe, 0xef,
3931 }; 3931 };
3932 3932
3933 SpdyFramer framer(spdy_version_); 3933 SpdyFramer framer(spdy_version_);
(...skipping 12 matching lines...) Expand all
3946 } 3946 }
3947 3947
3948 TEST_P(SpdyFramerTest, ExpectContinuationReceiveControlFrame) { 3948 TEST_P(SpdyFramerTest, ExpectContinuationReceiveControlFrame) {
3949 if (spdy_version_ <= SPDY3) { 3949 if (spdy_version_ <= SPDY3) {
3950 return; 3950 return;
3951 } 3951 }
3952 3952
3953 const unsigned char kInput[] = { 3953 const unsigned char kInput[] = {
3954 0x00, 0x10, 0x01, 0x00, // HEADERS 3954 0x00, 0x10, 0x01, 0x00, // HEADERS
3955 0x00, 0x00, 0x00, 0x01, // Stream 1 3955 0x00, 0x00, 0x00, 0x01, // Stream 1
3956 0x40, 0x06, 0x43, 0x6f, 3956 0x00, 0x06, 0x63, 0x6f,
3957 0x6f, 0x6b, 0x69, 0x65, 3957 0x6f, 0x6b, 0x69, 0x65,
3958 0x07, 0x66, 0x6f, 0x6f, 3958 0x07, 0x66, 0x6f, 0x6f,
3959 0x3d, 0x62, 0x61, 0x72, 3959 0x3d, 0x62, 0x61, 0x72,
3960 3960
3961 0x00, 0x14, 0x08, 0x00, // HEADERS 3961 0x00, 0x14, 0x08, 0x00, // HEADERS
3962 0x00, 0x00, 0x00, 0x01, // Stream 1 3962 0x00, 0x00, 0x00, 0x01, // Stream 1
3963 0x40, 0x06, 0x43, 0x6f, // (Note this is a valid continued encoding). 3963 0x00, 0x06, 0x63, 0x6f, // (Note this is a valid continued encoding).
3964 0x6f, 0x6b, 0x69, 0x65, 3964 0x6f, 0x6b, 0x69, 0x65,
3965 0x08, 0x62, 0x61, 0x7a, 3965 0x08, 0x62, 0x61, 0x7a,
3966 0x3d, 0x62, 0x69, 0x6e, 3966 0x3d, 0x62, 0x69, 0x6e,
3967 0x67, 0x40, 0x06, 0x43, 3967 0x67, 0x00, 0x06, 0x63,
3968 }; 3968 };
3969 3969
3970 SpdyFramer framer(spdy_version_); 3970 SpdyFramer framer(spdy_version_);
3971 TestSpdyVisitor visitor(spdy_version_); 3971 TestSpdyVisitor visitor(spdy_version_);
3972 framer.set_visitor(&visitor); 3972 framer.set_visitor(&visitor);
3973 visitor.SimulateInFramer(kInput, sizeof(kInput)); 3973 visitor.SimulateInFramer(kInput, sizeof(kInput));
3974 3974
3975 EXPECT_EQ(1, visitor.error_count_); 3975 EXPECT_EQ(1, visitor.error_count_);
3976 EXPECT_EQ(SpdyFramer::SPDY_UNEXPECTED_FRAME, 3976 EXPECT_EQ(SpdyFramer::SPDY_UNEXPECTED_FRAME,
3977 visitor.framer_.error_code()) 3977 visitor.framer_.error_code())
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
4746 4746
4747 EXPECT_CALL(debug_visitor, OnSendCompressedFrame(42, HEADERS, _, _)); 4747 EXPECT_CALL(debug_visitor, OnSendCompressedFrame(42, HEADERS, _, _));
4748 EXPECT_CALL(debug_visitor, OnReceiveCompressedFrame(42, HEADERS, _)); 4748 EXPECT_CALL(debug_visitor, OnReceiveCompressedFrame(42, HEADERS, _));
4749 EXPECT_CALL(visitor, OnHeaders(42, 0, false)); 4749 EXPECT_CALL(visitor, OnHeaders(42, 0, false));
4750 EXPECT_CALL(visitor, OnControlFrameHeaderData(42, _, _)) 4750 EXPECT_CALL(visitor, OnControlFrameHeaderData(42, _, _))
4751 .WillRepeatedly(testing::Return(true)); 4751 .WillRepeatedly(testing::Return(true));
4752 EXPECT_CALL(debug_visitor, OnSendCompressedFrame(42, CONTINUATION, _, _)); 4752 EXPECT_CALL(debug_visitor, OnSendCompressedFrame(42, CONTINUATION, _, _));
4753 4753
4754 SpdyHeadersIR headers_ir(42); 4754 SpdyHeadersIR headers_ir(42);
4755 headers_ir.SetHeader("foo", "bar"); 4755 headers_ir.SetHeader("foo", "bar");
4756 headers_ir.set_end_headers(false);
4757 scoped_ptr<SpdyFrame> frame0(framer.SerializeHeaders(headers_ir)); 4756 scoped_ptr<SpdyFrame> frame0(framer.SerializeHeaders(headers_ir));
4757 SetFrameFlags(frame0.get(), 0, spdy_version_);
4758 4758
4759 SpdyContinuationIR continuation(42); 4759 SpdyContinuationIR continuation(42);
4760 continuation.SetHeader("foo", "bar"); 4760 continuation.SetHeader("foo", "bar");
4761 scoped_ptr<SpdySerializedFrame> frame( 4761 scoped_ptr<SpdySerializedFrame> frame(
4762 framer.SerializeContinuation(continuation)); 4762 framer.SerializeContinuation(continuation));
4763 SetFrameFlags(frame.get(), flags, spdy_version_); 4763 SetFrameFlags(frame.get(), flags, spdy_version_);
4764 4764
4765 if (flags & ~(HEADERS_FLAG_END_HEADERS)) { 4765 if (flags & ~(HEADERS_FLAG_END_HEADERS)) {
4766 EXPECT_CALL(visitor, OnError(_)); 4766 EXPECT_CALL(visitor, OnError(_));
4767 } else { 4767 } else {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
4953 SpdyBlockedIR blocked_ir(0); 4953 SpdyBlockedIR blocked_ir(0);
4954 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); 4954 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir));
4955 framer.ProcessInput(frame->data(), framer.GetBlockedSize()); 4955 framer.ProcessInput(frame->data(), framer.GetBlockedSize());
4956 4956
4957 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); 4957 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state());
4958 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) 4958 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code())
4959 << SpdyFramer::ErrorCodeToString(framer.error_code()); 4959 << SpdyFramer::ErrorCodeToString(framer.error_code());
4960 } 4960 }
4961 4961
4962 } // namespace net 4962 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_framer.cc ('k') | net/spdy/spdy_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698