Code RoomHTTP auth header parser
MediumPrep Room Coding #328

HTTP auth header parser

CodingSecurityNetworking & APIsMid–Senior~22 min

Parse an HTTP Authorization / WWW-Authenticate header into its scheme and parameters. The header is 'Scheme param1=value1, param2="value 2", ...'. The scheme is the first whitespace-delimited token. Parameters follow as comma-separated key=value pairs; values may be bare tokens or double-quoted strings, and a quoted value may itself contain commas (which must NOT be treated as parameter separators). Strip surrounding quotes from values. If there are no parameters (e.g. 'Bearer abc123'), return an empty params dict. Return [scheme, params_dict].

Implement
parse_auth_params(header: str) → list
Examples
in["Digest realm=\"test\", nonce=\"abc\", qop=auth"]out["Digest",{"qop":"auth","nonce":"abc","realm":"test"}]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 22 min
InputExpectedGot
["Digest realm=\"test\", nonce=\"abc\", qop=auth"]["Digest",{"qop":"auth","nonce":"abc","realm":"test"}]not run yetsample