I think it's more appropriate to use ...getHeaders().put(...), as add() can result in multiple headers of the same name. Meaning that I would be unable to overwrite existing headers (such as the User-Agent).

Same below for the multi-value case (not sure if it's better to use one put and several add calls there, or just keep the comma-separated thing as now).