Skip to content

HTTP Request API ## Business Purpose

Provide a simple, uniform interface for sending HTTP requests of any method, automatically handling URL construction, parameter encoding, and response parsing. ## Current Behaviors - The request() function creates a session context manager and delegates to session.request() src/requests/api.py:24. - Convenience functions get(), options(), head(), post(), put(), patch(), delete() call request() with the appropriate method src/requests/api.py:24. - head() defaults allow_redirects to False src/requests/api.py:102. - The request() function accepts keyword arguments for data, json, files, headers, cookies, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, and params src/requests/_types.py:152. ## Technical Implementation The request function src/requests/api.py:24 instantiates a Session and calls its request method, which prepares and sends the request. All convenience functions are thin wrappers around request. ## Definition of Done - Sending a GET request via requests.get(url) returns a Response with status code 200 for a valid URL. - requests.post(url, data={"key":"value"}) sends a form-encoded body and receives a 200 response. - requests.head(url) does not follow redirects and returns the final response with status code 200. - requests.request('CUSTOM', url) works with any uppercase method string. - Passing an invalid timeout value raises ValueError.