// Conveniently handles converstion to/from wire format.
class NET_EXPORT_PRIVATE SettingsFlagsAndId {
public:
- static SettingsFlagsAndId FromWireFormat(int version, uint32 wire);
+ static SettingsFlagsAndId FromWireFormat(SpdyMajorVersion version,
+ uint32 wire);
SettingsFlagsAndId() : flags_(0), id_(0) {}
// TODO(hkhalil): restrict to enums instead of free-form ints.
SettingsFlagsAndId(uint8 flags, uint32 id);
- uint32 GetWireFormat(int version) const;
+ uint32 GetWireFormat(SpdyMajorVersion version) const;
uint32 id() const { return id_; }
uint8 flags() const { return flags_; }
void Reset() {
setting_buf_len = 0;
- last_setting_id = 0;
+ last_setting_id = -1;
}
// Buffer contains up to one complete key/value pair.
// The ID of the last setting that was processed in the current SETTINGS
// frame. Used for detecting out-of-order or duplicate keys within a settings
- // frame. Set to 0 before first key/value pair is processed.
- uint32 last_setting_id;
+ // frame. Set to -1 before first key/value pair is processed.
+ int last_setting_id;
};
// SpdyFramerVisitorInterface is a set of callbacks for the SpdyFramer.
SPDY_AUTO_RESET,
SPDY_READING_COMMON_HEADER,
SPDY_CONTROL_FRAME_PAYLOAD,
+ SPDY_READ_PADDING_LENGTH,
+ SPDY_CONSUME_PADDING,
SPDY_IGNORE_REMAINING_PAYLOAD,
SPDY_FORWARD_STREAM_FRAME,
SPDY_CONTROL_FRAME_BEFORE_HEADER_BLOCK,
// Serializes a SpdyHeaderBlock.
static void WriteHeaderBlock(SpdyFrameBuilder* frame,
- const int spdy_version,
+ const SpdyMajorVersion spdy_version,
const SpdyHeaderBlock* headers);
// Retrieve serialized length of SpdyHeaderBlock.
// TODO(hkhalil): Remove, or move to quic code.
- static size_t GetSerializedLength(const int spdy_version,
- const SpdyHeaderBlock* headers);
+ static size_t GetSerializedLength(
+ const SpdyMajorVersion spdy_version,
+ const SpdyHeaderBlock* headers);
// Create a new Framer, provided a SPDY version.
explicit SpdyFramer(SpdyMajorVersion version);
// Serialize a data frame.
SpdySerializedFrame* SerializeData(const SpdyDataIR& data) const;
- // Serializes just the data frame header, excluding actual data payload.
- SpdySerializedFrame* SerializeDataFrameHeader(const SpdyDataIR& data) const;
+ // Serializes the data frame header and optionally padding length fields,
+ // excluding actual data payload and padding.
+ SpdySerializedFrame* SerializeDataFrameHeaderWithPaddingLengthField(
+ const SpdyDataIR& data) const;
// Serializes a SYN_STREAM frame.
SpdySerializedFrame* SerializeSynStream(const SpdySynStreamIR& syn_stream);
// Returns the maximum size a frame can be (data or control).
size_t GetFrameMaximumSize() const;
+ // Returns the maximum size that a control frame can be.
+ size_t GetControlFrameMaximumSize() const;
+
// Returns the maximum payload size of a DATA frame.
size_t GetDataFrameMaximumPayload() const;
+ // Returns the prefix length for the given frame type.
+ size_t GetPrefixLength(SpdyFrameType type) const;
+
// For debugging.
static const char* StateToString(int state);
static const char* ErrorCodeToString(int error_code);
SpdyStreamId expect_continuation() const { return expect_continuation_; }
- SpdyPriority GetLowestPriority() const { return spdy_version_ < 3 ? 3 : 7; }
+ SpdyPriority GetLowestPriority() const {
+ return spdy_version_ < SPDY3 ? 3 : 7;
+ }
+
SpdyPriority GetHighestPriority() const { return 0; }
// Deliver the given control frame's compressed headers block to the visitor
size_t len);
protected:
+ // TODO(jgraettinger): Switch to test peer pattern.
FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, BasicCompression);
FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ControlFrameSizesAreValidated);
FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, HeaderCompression);
ReadLargeSettingsFrameInSmallChunks);
FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ControlFrameAtMaxSizeLimit);
FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ControlFrameTooLarge);
+ FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest,
+ TooLargeHeadersFrameUsesContinuation);
+ FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest,
+ TooLargePushPromiseFrameUsesContinuation);
friend class net::HttpNetworkLayer; // This is temporary for the server.
friend class net::HttpNetworkTransactionTest;
friend class net::HttpProxyClientSocketPoolTest;
size_t ProcessControlFrameHeaderBlock(const char* data,
size_t len,
bool is_hpack_header_block);
+ size_t ProcessFramePaddingLength(const char* data, size_t len);
+ size_t ProcessFramePadding(const char* data, size_t len);
size_t ProcessDataFramePayload(const char* data, size_t len);
size_t ProcessGoAwayFramePayload(const char* data, size_t len);
size_t ProcessRstStreamFramePayload(const char* data, size_t len);
size_t ProcessSettingsFramePayload(const char* data, size_t len);
+ size_t ProcessIgnoredControlFramePayload(/*const char* data,*/ size_t len);
// TODO(jgraettinger): To be removed with migration to
// SpdyHeadersHandlerInterface.
z_stream* GetHeaderCompressor();
z_stream* GetHeaderDecompressor();
+ size_t GetNumberRequiredContinuationFrames(size_t size);
+
+ void WritePayloadWithContinuation(SpdyFrameBuilder* builder,
+ const std::string& hpack_encoding,
+ SpdyStreamId stream_id,
+ SpdyFrameType type);
+
private:
// Deliver the given control frame's uncompressed headers block to the
// visitor in chunks. Returns true if the visitor has accepted all of the
SpdyState state_;
SpdyState previous_state_;
SpdyError error_code_;
+
+ // Note that for DATA frame, remaining_data_length_ is sum of lengths of
+ // frame header, padding length field (optional), data payload (optional) and
+ // padding payload (optional).
size_t remaining_data_length_;
+ // The length (in bytes) of the padding payload to be processed.
+ size_t remaining_padding_payload_length_;
+
+ // The length (in bytes) of the padding length field to be processed.
+ size_t remaining_padding_length_fields_;
+
// The number of bytes remaining to read from the current control frame's
// headers. Note that header data blocks (for control types that have them)
// are part of the frame's payload, and not the frame's headers.