| 498 | static char immortal_zeros[H2_MAX_PADLEN]; |
| 499 | |
| 500 | static int on_send_data_cb(nghttp2_session *ngh2, |
| 501 | nghttp2_frame *frame, |
| 502 | const uint8_t *framehd, |
| 503 | size_t length, |
| 504 | nghttp2_data_source *source, |
| 505 | void *userp) |
| 506 | { |
| 507 | apr_status_t status = APR_SUCCESS; |
| 508 | h2_session *session = (h2_session *)userp; |
| 509 | int stream_id = (int)frame->hd.stream_id; |
| 510 | unsigned char padlen; |
| 511 | int eos; |
| 512 | h2_stream *stream; |
| 513 | apr_bucket *b; |
| 514 | apr_off_t len = length; |
| 515 | |
| 516 | (void)ngh2; |
| 517 | (void)source; |
| 518 | ap_assert(frame->data.padlen <= (H2_MAX_PADLEN+1)); |
| 519 | padlen = (unsigned char)frame->data.padlen; |
| 520 | |
| 521 | stream = get_stream(session, stream_id); |
| 522 | if (!stream) { |
| 523 | ap_log_cerror(APLOG_MARK, APLOG_ERR, APR_NOTFOUND, session->c1, |
| 524 | APLOGNO(02924) |
| 525 | H2_SSSN_STRM_MSG(session, stream_id, "send_data, stream not found")); |
| 526 | return NGHTTP2_ERR_CALLBACK_FAILURE; |
| 527 | } |
| 528 | |
| 529 | ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c1, |
| 530 | H2_STRM_MSG(stream, "send_data_cb for %ld bytes"), |
| 531 | (long)length); |
| 532 | |
| 533 | status = h2_c1_io_add_data(&session->io, (const char *)framehd, H2_FRAME_HDR_LEN); |
| 534 | if (padlen && status == APR_SUCCESS) { |
| 535 | --padlen; |
| 536 | status = h2_c1_io_add_data(&session->io, (const char *)&padlen, 1); |
| 537 | } |
| 538 | |
| 539 | if (status != APR_SUCCESS) { |
| 540 | ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, session->c1, |
| 541 | H2_STRM_MSG(stream, "writing frame header")); |
| 542 | return NGHTTP2_ERR_CALLBACK_FAILURE; |
| 543 | } |
| 544 | |
| 545 | status = h2_stream_read_to(stream, session->bbtmp, &len, &eos); |
| 546 | if (status != APR_SUCCESS) { |
| 547 | ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, session->c1, |
| 548 | H2_STRM_MSG(stream, "send_data_cb, reading stream")); |
| 549 | apr_brigade_cleanup(session->bbtmp); |
| 550 | return NGHTTP2_ERR_CALLBACK_FAILURE; |
| 551 | } |
| 552 | else if (len != (apr_off_t)length) { |
| 553 | ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, session->c1, |
| 554 | H2_STRM_MSG(stream, "send_data_cb, wanted %ld bytes, " |
| 555 | "got %ld from stream"), (long)length, (long)len); |
| 556 | apr_brigade_cleanup(session->bbtmp); |
| 557 | return NGHTTP2_ERR_CALLBACK_FAILURE; |
nothing calls this directly
no test coverage detected