Thanks for the links.

When I was referring to "garbage" on either side of charset=, I was indeed referring to what those standards say is "linear white space". However, my code also takes into account other non-alphanumeric tokens so it at least needs to be changed to only strip whitespace characters.

If we want to go with the assumption that libcurl will always trim whitespace on either side of the parameter then we can drop this solution and explicitly document in the code that we're expecting libcurl to do this for us.

(If you could point me to the function in libcurl that sanitises HTTP headers then I can add an automated integration test to make sure it always does that).

However, if we want to use this code outside of the context of having libcurl perform transport then we need to handle any amount of linear white space on either side of charset= because the spec doesn't suggest that you can only have one or zero linear white spaces between two tokens. In that case, we need to, at the very least, handle HTTP headers where any amount of linear whitespace could appear between type/subtype and the parameter.

What do you think?