<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Net/Http on Moises Vega</title><link>https://mvega.dev/tags/net/http/</link><description>Recent content in Net/Http on Moises Vega</description><generator>Hugo</generator><language>en-us</language><copyright>Moises Vega</copyright><lastBuildDate>Thu, 20 Aug 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://mvega.dev/tags/net/http/index.xml" rel="self" type="application/rss+xml"/><item><title>When Request.Body.Close Started Returning io.EOF</title><link>https://mvega.dev/posts/go-http-body-close-eof/</link><pubDate>Thu, 20 Aug 2026 00:00:00 +0000</pubDate><guid>https://mvega.dev/posts/go-http-body-close-eof/</guid><description>&lt;p&gt;While testing an internal HTTP service against Go 1.27, a handler that
had worked for years started reporting errors from an unlikely place:
&lt;code&gt;r.Body.Close()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The handler does what any length-aware decoder does — it reads exactly
the payload it expects and stops, without reading far enough to observe
&lt;code&gt;io.EOF&lt;/code&gt;. Then it closes the body. On Go 1.26 that &lt;code&gt;Close&lt;/code&gt; returned
&lt;code&gt;nil&lt;/code&gt;. On 1.27 it returns &lt;code&gt;io.EOF&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="pinning-it-down"&gt;Pinning it down&lt;/h2&gt;
&lt;p&gt;Timer-driven HTTP repros are flaky, so I drove &lt;code&gt;net/http&lt;/code&gt; over a
&lt;code&gt;net.Pipe&lt;/code&gt; with a one-shot listener: fully deterministic, no real
sockets, no timeouts. The whole thing fits in a
&lt;a href="https://go.dev/play/p/P6gM5GS84Vq"&gt;playground link&lt;/a&gt;. A handler reads 2
of 4 body bytes, closes, and reports the error:&lt;/p&gt;</description></item></channel></rss>