| 250 | } |
| 251 | |
| 252 | int |
| 253 | Http2CommonSession::do_start_frame_read(Http2ErrorCode &ret_error) |
| 254 | { |
| 255 | ret_error = Http2ErrorCode::HTTP2_ERROR_NO_ERROR; |
| 256 | ink_release_assert(this->_read_buffer_reader->read_avail() >= (int64_t)HTTP2_FRAME_HEADER_LEN); |
| 257 | |
| 258 | uint8_t buf[HTTP2_FRAME_HEADER_LEN]; |
| 259 | unsigned nbytes; |
| 260 | |
| 261 | Http2SsnDebug("receiving frame header"); |
| 262 | nbytes = copy_from_buffer_reader(buf, this->_read_buffer_reader, sizeof(buf)); |
| 263 | |
| 264 | this->cur_frame_from_early_data = false; |
| 265 | if (!http2_parse_frame_header(make_iovec(buf), this->current_hdr)) { |
| 266 | Http2SsnDebug("frame header parse failure"); |
| 267 | this->get_proxy_session()->do_io_close(); |
| 268 | return -1; |
| 269 | } |
| 270 | |
| 271 | // Check whether data is read from early data |
| 272 | if (this->read_from_early_data > 0) { |
| 273 | this->read_from_early_data -= this->read_from_early_data > nbytes ? nbytes : this->read_from_early_data; |
| 274 | this->cur_frame_from_early_data = true; |
| 275 | } |
| 276 | |
| 277 | Http2SsnDebug("frame header length=%u, type=%u, flags=0x%x, streamid=%u, early_data=%d", (unsigned)this->current_hdr.length, |
| 278 | (unsigned)this->current_hdr.type, (unsigned)this->current_hdr.flags, this->current_hdr.streamid, |
| 279 | this->cur_frame_from_early_data); |
| 280 | |
| 281 | this->_read_buffer_reader->consume(nbytes); |
| 282 | |
| 283 | if (!http2_frame_header_is_valid(this->current_hdr, this->connection_state.local_settings.get(HTTP2_SETTINGS_MAX_FRAME_SIZE))) { |
| 284 | ret_error = Http2ErrorCode::HTTP2_ERROR_PROTOCOL_ERROR; |
| 285 | return -1; |
| 286 | } |
| 287 | |
| 288 | // If we know up front that the payload is too long, nuke this connection. |
| 289 | if (this->current_hdr.length > this->connection_state.local_settings.get(HTTP2_SETTINGS_MAX_FRAME_SIZE)) { |
| 290 | ret_error = Http2ErrorCode::HTTP2_ERROR_FRAME_SIZE_ERROR; |
| 291 | return -1; |
| 292 | } |
| 293 | |
| 294 | // CONTINUATIONs MUST follow behind HEADERS which doesn't have END_HEADERS |
| 295 | Http2StreamId continued_stream_id = this->connection_state.get_continued_stream_id(); |
| 296 | |
| 297 | if (continued_stream_id != 0 && |
| 298 | (continued_stream_id != this->current_hdr.streamid || this->current_hdr.type != HTTP2_FRAME_TYPE_CONTINUATION)) { |
| 299 | ret_error = Http2ErrorCode::HTTP2_ERROR_PROTOCOL_ERROR; |
| 300 | return -1; |
| 301 | } |
| 302 | return 0; |
| 303 | } |
| 304 | |
| 305 | int |
| 306 | Http2CommonSession::state_complete_frame_read(int event, void *edata) |
nothing calls this directly
no test coverage detected