harbor run -t openthoughts/tasktrove-exp-rpt-stack-rust-v2-stack-rust-3654harbor download openthoughts/tasktrove-exp-rpt-stack-rust-v2-stack-rust-3654Task Description: Implement HTTP Client Functionality
You are required to implement the functionality of the Client struct used for executing HTTP requests in an application. This includes setting up the HTTP client, managing request specifications, handling redirects, and parsing responses. Your implementation should satisfy the following requirements:
Initialization:
init method to initialize the Client struct with ClientOptions. The method should configure the HTTP client to use a cookie file for cookie storage according to the provided options.Request Execution:
execute method to send an HTTP request based on the given RequestSpec.set_method, set_headers, set_body, etc.).Result tuple with the corresponding request.Handling Redirects:
execute_with_redirect method to handle HTTP redirects (3xx responses). The method should:
max_redirect specified in ClientOptions.Support for HTTP Headers and Cookies:
set_headers), cookies (set_cookies), and form data (set_form, set_multipart).Implement Response Parsing:
Error Handling:
HttpError enums).Unit Testing:
execute, execute_with_redirect, and cookie handling.After implementing the above functionalities, make sure to place your solution in the /app/ directory of the project, maintaining existing code structure and conventions.