Skip to content

Commit 2f0a306

Browse files
committed
doc: add net/http section to go1.8.html
TBR=See https://golang.org/cl/33244 and review there. Updates #17929 Change-Id: I752ec7a6d086f370feaf3cf282708620e891079b Reviewed-on: https://go-review.googlesource.com/33478 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 75c1381 commit 2f0a306

File tree

2 files changed

+147
-31
lines changed

2 files changed

+147
-31
lines changed

doc/go1.8.html

Lines changed: 120 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,15 @@ <h3 id="h2push">HTTP/2 Push</h3>
314314
<a href="/pkg/net/http/#Pusher"><code>Pusher</code></a> interface.
315315
</p>
316316

317-
<h3 id="httpshutdown">HTTP Server Graceful Shutdown</h3>
317+
<h3 id="http_shutdown">HTTP Server Graceful Shutdown</h3>
318+
319+
<p> <!-- CL 32329 -->
320+
The HTTP Server now has support for graceful shutdown using the new
321+
<a href="/pkg/net/http/#Server.Shutdown"><code>Server.Shutdown</code></a>
322+
method. The related and more abrupt
323+
<a href="/pkg/net/http/#Server.Close"><code>Server.Close</code></a>
324+
is also new.
325+
</p>
318326

319327
<h3 id="minor_library_changes">Minor changes to the library</h3>
320328

@@ -556,9 +564,118 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
556564
<dl id="net_http"><dt><a href="/pkg/net/http/">net/http</a></dt>
557565
<dd>
558566

567+
<p>Server changes:</p>
568+
<ul>
569+
<li>The server now supports graceful shutdown support, <a href="#http_shutdown">mentioned above</a>.</li>
570+
571+
<li> <!-- CL 32024 -->
572+
The <a href="/pkg/net/http/#Server"><code>Server</code></a> now
573+
has new configuration options
574+
<code>ReadHeaderTimeout</code> and <code>IdleTimeout</code>.
575+
The previously ill-defined <code>WriteTimeout</code> is now
576+
documented.
577+
</li>
578+
579+
<li> <!-- CL 32014 -->
580+
<a href="/pkg/net/http/#FileServer"><code>FileServer</code></a>
581+
and
582+
<a href="/pkg/net/http/#ServeContent"><code>ServeContent</code></a>
583+
now support HTTP <code>If-Match</code> conditional requests,
584+
in addition to the previous <code>If-None-Match</code>
585+
support.
586+
</li>
587+
588+
<li> <!-- CL 27950 -->
589+
The server now logs bad requests.
590+
</li>
591+
</ul>
592+
559593
<p>
560-
TODO
561-
</p>
594+
There are several additions to what a server's <code>Handler</code> can do:
595+
</p>
596+
597+
<ul>
598+
<li><!-- CL 31173 -->
599+
The <a href="/pkg/context/#Context"><code>Context</code></a>
600+
returned
601+
by <a href="/pkg/net/http/#Request.Context"><code>Request.Context</code></a>
602+
is canceled if the underlying <code>net.Conn</code>
603+
closes. For instance, if the user closes their browser in the
604+
middle of a slow request, the <code>Handler</code> can now
605+
detect that the user is gone. This complements the
606+
existing <a href="/pkg/net/http/#CloseNotifier"><code>CloseNotifier</code></a>
607+
support.
608+
</li>
609+
610+
<li><!-- CL 32479 --> There is now a second way to serve trailers
611+
for when the trailer name is not known before the headers are
612+
written (via a call to
613+
to <code>ResponseWriter.WriteHeader</code>). The old way
614+
continues to work, but when the trailer is only known after the
615+
header has been written, see the
616+
new <a href="/pkg/net/http/#TrailerPrefix"><code>TrailerPrefix</code></a>.</li>
617+
618+
<li><!-- CL 33099 -->
619+
A <code>Handler</code> now has a supported mechanism to abort a
620+
response: panicking with
621+
<a href="/pkg/net/http/#ErrAbortHandler"><code>ErrAbortHandler</code></a>.
622+
</li>
623+
624+
<li><!-- CL 30812 -->
625+
There is now a supported mechanism to test whether a
626+
<code>ResponseWriter</code> has been hijacked: <code>Write</code> zero bytes to it.
627+
While this previously returned
628+
<a href="/pkg/net/http/#ErrHijacked"><code>ErrHijacked</code></a>, now
629+
it also does so without spamming the server's error log.
630+
</li>
631+
632+
</ul>
633+
634+
<p>Client &amp; Transport changes:</p>
635+
<ul>
636+
<li><!-- CL 28930 -->
637+
The <code>Client</code> now copies request headers on redirect.
638+
</li>
639+
640+
<li><!-- CL 29072 -->
641+
The <code>Transport</code> now supports international domain names.
642+
</li>
643+
644+
<li><!-- CL 31733, CL 29852 -->
645+
The <code>Client</code> now supports 307 and 308 redirects.
646+
If the redirect involves re-sending the request body,
647+
the request must have the new
648+
<a href="/pkg/net/http/#Request"><code>Request.GetBody</code></a>
649+
field defined.
650+
<a href="pkg/net/http/#NewRequest"><code>NewRequest</code></a>
651+
sets <code>Request.GetBody</code> automatically for common
652+
body types.
653+
</li>
654+
655+
<li><!-- CL 32482 -->
656+
The <code>Transport</code> now rejects requests for URLs with
657+
ports containing non-digit characters.
658+
</li>
659+
660+
<li><!-- CL 27117 -->
661+
The <code>Transport</code> will now retry non-idempotent
662+
requests if no bytes were written before a network failure.
663+
</li>
664+
665+
<li><!-- CL 32481 -->
666+
The
667+
new <a href="/pkg/net/http/#Transport"><code>Transport.ProxyConnectHeader</code></a>
668+
allows configuration of header values to send to a proxy
669+
during a <code>CONNECT</code> request.
670+
</li>
671+
672+
<li> <!-- CL 28077 -->
673+
The <a href="/pkg/net/http/#DefaultTransport"><code>DefaultTransport.Dialer</code></a>
674+
now enables <code>DualStack</code> ("Happy Eyeballs") support,
675+
to use IPv4 as a backup if it looks like IPv6 might be
676+
failing.
677+
</li>
678+
</ul>
562679

563680
</dd>
564681
</dl>

doc/go1.8.txt

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -172,34 +172,6 @@ net/http/httputil: make ReverseProxy send nil Body requests when possible (CL 28
172172
net/http/httputil: remove custom hop-by-hop headers from response in ReverseProxy (CL 28810)
173173
net/http/httputil: remove proxied headers mentioned in connection-tokens (CL 27970)
174174

175-
net/http, net/http/httptest: make http2's TrailerPrefix work for http1 (CL 32479)
176-
net/http: add ErrAbortHandler, make Server quiet if used as panic value (CL 33099)
177-
net/http: add NoBody, don't return nil from NewRequest on zero bodies (CL 31726)
178-
net/http: add Request.GetBody func for 307/308 redirects (CL 31733)
179-
net/http: add Server.Close & Server.Shutdown for forced & graceful shutdown (CL 32329)
180-
net/http: add Server.ReadHeaderTimeout, IdleTimeout, document WriteTimeout (CL 32024)
181-
net/http: add Transport.ProxyConnectHeader to control headers to proxies (CL 32481)
182-
net/http: allow Handlers to test Hijacked conn without spamming error log (CL 30812)
183-
net/http: don't sniff Request.Body on 100-continue requests in Transport (CL 30151)
184-
net/http: handle 3xx redirects properly (CL 29852)
185-
net/http: make Client copy headers on redirect (CL 28930)
186-
net/http: make DefaultTransport's Dialer enable DualStack ("Happy Eyeballs") (CL 28077)
187-
net/http: make NewRequest set empty Body nil, don't peek Read Body in Transport (CL 31445)
188-
net/http: make Redirect escape non-ASCII in Location header (CL 31732)
189-
net/http: make Server Handler's Request.Context be done on conn errors (CL 31173)
190-
net/http: make Server log on bad requests from clients (CL 27950)
191-
net/http: make Transport reject URLs with bogus ports with non-digits (CL 32482)
192-
net/http: make Transport retry non-idempotent requests if no bytes written (CL 27117)
193-
net/http: make Transport support international domain names (CL 29072)
194-
net/http: omit Content-Length in Response.Write for 1xx or 204 status (CL 28351)
195-
net/http: returned typed error on Transport proxy dial (CL 30750)
196-
net/http: send Content-Range if no byte range overlaps (CL 24212)
197-
net/http: skip test needing good DNS in short mode, except on builders (CL 28782)
198-
net/http: support If-Match in ServeContent (CL 32014)
199-
net/http: support multiple identical Content-Length headers (CL 31252)
200-
net/http: update bundled http2 for ErrAbortHandler support, document it more (CL 33103)
201-
net/http: update bundled http2, add h2 Transport.IdleConnTimeout tests (CL 30078)
202-
203175
net: add (*UnixListener).SetUnlinkOnClose (CL 32099)
204176
net: add Buffers type, do writev on unix (CL 29951)
205177
net: implement Buffers on windows (CL 32371)
@@ -458,7 +430,34 @@ lib/time: update tzdata to 2016i (CL 33029)
458430
math/rand: add Rand.Uint64 (CL 27253)
459431
mime/quotedprintable: accept = not followed by 2 hex digits as literal equals (CL 32174)
460432
mime/quotedprintable: accept trailing soft line-break at the end of message (CL 27530)
433+
net/http, net/http/httptest: make http2's TrailerPrefix work for http1 (CL 32479)
434+
net/http: add ErrAbortHandler, make Server quiet if used as panic value (CL 33099)
435+
net/http: add NoBody, don't return nil from NewRequest on zero bodies (CL 31726)
436+
net/http: add Request.GetBody func for 307/308 redirects (CL 31733)
437+
net/http: add Server.Close & Server.Shutdown for forced & graceful shutdown (CL 32329)
438+
net/http: add Server.ReadHeaderTimeout, IdleTimeout, document WriteTimeout (CL 32024)
439+
net/http: add Transport.ProxyConnectHeader to control headers to proxies (CL 32481)
461440
net/http: add an interface for HTTP/2 server push (CL 32012)
441+
net/http: allow Handlers to test Hijacked conn without spamming error log (CL 30812)
442+
net/http: don't sniff Request.Body on 100-continue requests in Transport (CL 30151)
443+
net/http: handle 3xx redirects properly (CL 29852)
444+
net/http: make Client copy headers on redirect (CL 28930)
445+
net/http: make DefaultTransport's Dialer enable DualStack ("Happy Eyeballs") (CL 28077)
446+
net/http: make NewRequest set empty Body nil, don't peek Read Body in Transport (CL 31445)
447+
net/http: make Redirect escape non-ASCII in Location header (CL 31732)
448+
net/http: make Server Handler's Request.Context be done on conn errors (CL 31173)
449+
net/http: make Server log on bad requests from clients (CL 27950)
450+
net/http: make Transport reject URLs with bogus ports with non-digits (CL 32482)
451+
net/http: make Transport retry non-idempotent requests if no bytes written (CL 27117)
452+
net/http: make Transport support international domain names (CL 29072)
453+
net/http: omit Content-Length in Response.Write for 1xx or 204 status (CL 28351)
454+
net/http: returned typed error on Transport proxy dial (CL 30750)
455+
net/http: send Content-Range if no byte range overlaps (CL 24212)
456+
net/http: skip test needing good DNS in short mode, except on builders (CL 28782)
457+
net/http: support If-Match in ServeContent (CL 32014)
458+
net/http: support multiple identical Content-Length headers (CL 31252)
459+
net/http: update bundled http2 for ErrAbortHandler support, document it more (CL 33103)
460+
net/http: update bundled http2, add h2 Transport.IdleConnTimeout tests (CL 30078)
462461
net/mail: allow empty quoted string name in address again (CL 32176)
463462
net/mail: expose ParseDate, for use parsing Resent-Date headers (CL 31581)
464463
net/smtp: make Client.Auth trim final space if Auth.Start toServer is empty (CL 33143)

0 commit comments

Comments
 (0)