Various refactorings
See commits. This is just various minor refactorings that accumulated while working on Draft: Support passing empty and binary HTTP he... (!1906 - closed). I'd like to merge them separately to reduce the size of that MR.
Relates to https://gitlab.com/gitlab-com/ops-sub-department/section-ops-request-for-help/-/issues/451.