I want to make a comment about line 40 above (alas, GitHub refuses): You could probably save a few memory allocations by iterating through headers and writing that out directly to ``conn`` instead of grouping it all into a temporary buffer that just gets thrown away.  Not a big deal, but this is library code.  :)