115 points allddd 3 hours ago 20 comments
jamesponddotco 2 hours ago | parent
[1]: https://github.com/cipherdothost/x-go/blob/caa562ded82b8c417...
aleksi 1 hour ago | parent
jamesponddotco 1 hour ago | parent
Not because of the copy itself, since a little copy is better than a little dependency, as they say, but because it was a pain to update everything when I inevitably found a bug in what I copied.
nasretdinov 1 hour ago | parent
prussian 1 hour ago | parent
jerf 1 hour ago | parent
I can attest to the fact this is a Frequently Asked Question among people who are trying to Go as an HTTP client, so even though this feels somewhat icky, I can understand where it is coming from. However, I'm also missing, if I want to slam this connection closed, which is a reasonable thing to want, how do I do that without uselessly draining a socket I don't intend to reuse? Fake the "Connection: close" header into the Response object? Hope I can dig out an underlying socket of some sort under the concrete type of the Body.Response that I can bypass this code with? Seems like there should be a way to do that too.
aleksi 1 hour ago | parent
> Note, however, that Transport will automatically try to read a Response Body to EOF asynchronously up to a conservative limit when a Body is closed.
Similar wording appears in a few other places; search for “asynchronously”.
jerf 1 hour ago | parent
jchw 1 hour ago | parent
rkuska 1 hour ago | parent
Decoder only reads X bytes (512? I don’t remember) and if the structure fits into these bytes exactly (and the multiplications of it) the newline leaves hanging there.
I always check for Decoder.More (this drains whitespace) after decoding.
gandreani 34 minutes ago | parent
donatj 1 hour ago | parent
Does this mean I need to disable http2 for this to work or is that just a further proof that http2 isn't actually being used?
80fj0348i 1 hour ago | parent
giovannibajo1 1 hour ago | parent
MrDOS 1 hour ago | parent
seki285 49 minutes ago | parent
trgn 47 minutes ago | parent
afavour 45 minutes ago | parent
nasretdinov 38 minutes ago | parent
gandreani 27 minutes ago | parent
1. Suggest drainAndCloseBody // Team: this is reasonable
2. Implement drainAndCloseBodyWithTimer // Team: no problems here
3. then drainAsyncAndCloseBodyWithTimer // Team: a bit wordy but no problem here
4. Someone at google uses 3. with an http/2 connection // Team: this is where we draw the line?
I sympathize with the struggle of following golang's mission to be simple when you consider this common but tricky edge case. Iteration 3 makes sense but by gosh is it ugly ha.