I have the following string which is the value from WWW-Authenticate from a http request:
"Digest realm=\"Web Service Realm via Digest Authentication\", qop=\"auth\", nonce=\"MTU3MjchuUVEIHEUnVNV==\""
I need to convert this into a map so I can easily reference the values for realm and nonce. I have some working code which is very brittle, e.g. to extract the realm:
headers
|> String.split(",")
|> List.first()
|> String.split("=")
|> List.last()
|> String.replace("\"", "")
However, this isn't great because it relies on the realm being the first in the list. Whats the most optimal way of converting this data?