MCPcopy Create free account
hub / github.com/apache/httpd / select_padding_cb

Function select_padding_cb

modules/http2/h2_session.c:680–709  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

678#endif
679
680static ssize_t select_padding_cb(nghttp2_session *ngh2,
681 const nghttp2_frame *frame,
682 size_t max_payloadlen, void *user_data)
683{
684 h2_session *session = user_data;
685 size_t frame_len = frame->hd.length + H2_FRAME_HDR_LEN; /* the total length without padding */
686 size_t padded_len = frame_len;
687
688 /* Determine # of padding bytes to append to frame. Unless session->padding_always
689 * the number my be capped by the ui.write_size that currently applies.
690 */
691 if (session->padding_max) {
692 int n = ap_random_pick(0, session->padding_max);
693 padded_len = H2MIN(max_payloadlen + H2_FRAME_HDR_LEN, frame_len + n);
694 }
695
696 if (padded_len != frame_len) {
697 if (!session->padding_always && session->io.write_size
698 && (padded_len > session->io.write_size)
699 && (frame_len <= session->io.write_size)) {
700 padded_len = session->io.write_size;
701 }
702 ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c1,
703 "select padding from [%d, %d]: %d (frame length: 0x%04x, write size: %d)",
704 (int)frame_len, (int)max_payloadlen+H2_FRAME_HDR_LEN,
705 (int)(padded_len - frame_len), (int)padded_len, (int)session->io.write_size);
706 return padded_len - H2_FRAME_HDR_LEN;
707 }
708 return frame->hd.length;
709}
710
711#define NGH2_SET_CALLBACK(callbacks, name, fn)\
712nghttp2_session_callbacks_set_##name##_callback(callbacks, fn)

Callers

nothing calls this directly

Calls 1

ap_random_pickFunction · 0.85

Tested by

no test coverage detected