HTTP request parsing

Write codeMedium20 minStripe and Shopify style

Your task

Parse a raw HTTP request. The request is a string with lines separated by CRLF (\r\n); the request line comes first (METHOD PATH VERSION), followed by zero or more 'Name: Value' header lines, terminated by a blank line. Return [method, path, version, headers] where headers is a dict mapping lowercased header names to their trimmed values. Assume each header name appears at most once.

Examples

parse_request(raw: str) -> list
Example 1
Inputparse_request("GET /index.html HTTP/1.1\r\nHost: example.com\r\nAccept: text/html\r\n\r\n")
Output["GET", "/index.html", "HTTP/1.1", {"host": "example.com", "accept": "text/html"}]