request API rework

New request functions and some tests.

See request.h.