http: extract request creation code