]> Cypherpunks repositories - gostls13.git/commitdiff
net/http/httptrace: add simple example and fix copyright header
authorBilly Lynch <wlynch@google.com>
Fri, 19 Aug 2016 05:40:08 +0000 (01:40 -0400)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 22 Aug 2016 18:57:04 +0000 (18:57 +0000)
Partially addresses #16360

Change-Id: I67a328302d7d91231f348d934e4232fcb844830a
Reviewed-on: https://go-review.googlesource.com/27398
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/net/http/httptrace/example_test.go [new file with mode: 0644]
src/net/http/httptrace/trace.go
src/net/http/httptrace/trace_test.go

diff --git a/src/net/http/httptrace/example_test.go b/src/net/http/httptrace/example_test.go
new file mode 100644 (file)
index 0000000..c8ed446
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package httptrace_test
+
+import (
+       "fmt"
+       "net/http"
+       "net/http/httptrace"
+)
+
+func ExampleTrace() {
+       req, _ := http.NewRequest("GET", "http://example.com", nil)
+       trace := &httptrace.ClientTrace{
+               GotConn: func(connInfo httptrace.GotConnInfo) {
+                       fmt.Printf("Got Conn: %+v\n", connInfo)
+               },
+               DNSDone: func(dnsInfo httptrace.DNSDoneInfo) {
+                       fmt.Printf("DNS Info: %+v\n", dnsInfo)
+               },
+       }
+       req = req.WithContext(httptrace.WithClientTrace(req.Context(), trace))
+       http.DefaultClient.Do(req)
+}
index 6f187a7b694a84d47823a32d14c19a34faaf405b..93c07b8ac3a5ba0daf6948b0763b01779856f9a0 100644 (file)
@@ -1,6 +1,6 @@
 // Copyright 2016 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.h
+// license that can be found in the LICENSE file.
 
 // Package httptrace provides mechanisms to trace the events within
 // HTTP client requests.
index 77941b351980d5d2af0621d7162988dcfbceb5ed..bb57ada8531322e1988de133ff19287b9e0e8839 100644 (file)
@@ -1,6 +1,6 @@
 // Copyright 2016 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.h
+// license that can be found in the LICENSE file.
 
 package httptrace