Keyboard Shortcuts

File
u :up to issue
m :publish + mail comments
M :edit review message
j / k :jump to file after / before current file
J / K :jump to next file with a comment after / before current file
Side-by-side diff
i :toggle intra-line diffs
e :expand all comments
c :collapse all comments
s :toggle showing all comments
n / p :next / previous diff chunk or comment
N / P :next / previous comment
<Up> / <Down> :next / previous line
<Enter> :respond to / edit current comment
d :mark current comment as done
Issue
u :up to list of issues
m :publish + mail comments
j / k :jump to patch after / before current patch
o / <Enter> :open current patch in side-by-side view
i :open current patch in unified diff view
Issue List
j / k :jump to issue after / before current issue
o / <Enter> :open current issue
# : close issue
Comment/message editing
<Ctrl> + s or <Ctrl> + Enter :save comment
<Esc> :cancel edit
Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(29)
Issues Repositories Search
Open Issues | Closed Issues | All Issues | Sign in with your Google Account to create issues and add comments

Issue 7314046: code review 7314046: net/http/httptest: add examples

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 11 months ago by kisielk
Modified:
12 years, 5 months ago
Reviewers:
bradfitz
CC:
golang-dev, adg, bradfitz
Visibility:
Public.
net/http/httptest: add examples

Patch Set 1 #

Patch Set 2 : diff -r 8d71734a0cb0 https://code.google.com/p/go/ #

Patch Set 3 : diff -r 8d71734a0cb0 https://code.google.com/p/go/ #

Total comments: 10

Patch Set 4 : diff -r 052cab218361 https://code.google.com/p/go/ #

Total comments: 1

Patch Set 5 : diff -r 052cab218361 https://code.google.com/p/go/ #

Created: 12 years, 11 months ago
Download [raw] [tar.bz2]
Unified diffs Side-by-side diffs Delta from patch set Stats (+50 lines, -0 lines) Patch
A src/pkg/net/http/httptest/example_test.go View 1 2 3 4 1 chunk +50 lines, -0 lines 0 comments Download
Total messages: 9
|
kisielk
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go/
12 years, 11 months ago (2013年02月06日 05:38:24 UTC) #1
Hello golang-dev@googlegroups.com,
I'd like you to review this change to
https://code.google.com/p/go/ 
Sign in to reply to this message.
adg
Nice examples https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/example_test.go File src/pkg/net/http/httptest/example_test.go (right): https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/example_test.go#newcode17 src/pkg/net/http/httptest/example_test.go:17: http.Error(w, req.URL.Path+": something went horribly wrong.", http.StatusInternalServerError) ...
12 years, 11 months ago (2013年02月07日 22:21:43 UTC) #2
Nice examples
https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/ex...
File src/pkg/net/http/httptest/example_test.go (right):
https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/ex...
src/pkg/net/http/httptest/example_test.go:17: http.Error(w, req.URL.Path+":
something went horribly wrong.", http.StatusInternalServerError)
remove the period from the message
https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/ex...
src/pkg/net/http/httptest/example_test.go:29: //Output: 500 - /foo: something
went horribly wrong.
"// Output:"
add the space.
https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/ex...
src/pkg/net/http/httptest/example_test.go:50: //Output: Hello, client
ditto
Sign in to reply to this message.
bradfitz
https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/example_test.go File src/pkg/net/http/httptest/example_test.go (right): https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/example_test.go#newcode36 src/pkg/net/http/httptest/example_test.go:36: server := httptest.NewServer(http.HandlerFunc(handler)) in all the net/http tests, we ...
12 years, 11 months ago (2013年02月07日 22:31:14 UTC) #3
https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/ex...
File src/pkg/net/http/httptest/example_test.go (right):
https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/ex...
src/pkg/net/http/httptest/example_test.go:36: server :=
httptest.NewServer(http.HandlerFunc(handler))
in all the net/http tests, we never make a variable for "handler" even... just:
server := httptest.NewServer(http.HandlerFunc(w http.ResponseWriter, req
*http.Request) {
 ....
})
defer server.Close()
We also normally say "ts", but "server" is fine.
https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/ex...
src/pkg/net/http/httptest/example_test.go:41: log.Fatal("server did not
respond")
how do you know? maybe there was no DNS and you never even reached the server.
don't throw out err. it tries to say something useful.
Sign in to reply to this message.
kisielk
Thanks for the feedback, PTAL. https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/example_test.go File src/pkg/net/http/httptest/example_test.go (right): https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/example_test.go#newcode17 src/pkg/net/http/httptest/example_test.go:17: http.Error(w, req.URL.Path+": something went ...
12 years, 11 months ago (2013年02月08日 03:09:44 UTC) #4
Thanks for the feedback, PTAL.
https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/ex...
File src/pkg/net/http/httptest/example_test.go (right):
https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/ex...
src/pkg/net/http/httptest/example_test.go:17: http.Error(w, req.URL.Path+":
something went horribly wrong.", http.StatusInternalServerError)
On 2013年02月07日 22:21:43, adg wrote:
> remove the period from the message
Done
https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/ex...
src/pkg/net/http/httptest/example_test.go:29: //Output: 500 - /foo: something
went horribly wrong.
On 2013年02月07日 22:21:43, adg wrote:
> "// Output:"
> 
> add the space.
Done
https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/ex...
src/pkg/net/http/httptest/example_test.go:36: server :=
httptest.NewServer(http.HandlerFunc(handler))
On 2013年02月07日 22:31:14, bradfitz wrote:
> in all the net/http tests, we never make a variable for "handler" even...
just:
> 
> server := httptest.NewServer(http.HandlerFunc(w http.ResponseWriter, req
> *http.Request) {
> ....
> })
> defer server.Close()
> 
> We also normally say "ts", but "server" is fine.
I took a look at how this was used in net/http and reworked it in to a similar
style.
https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/ex...
src/pkg/net/http/httptest/example_test.go:41: log.Fatal("server did not
respond")
On 2013年02月07日 22:31:14, bradfitz wrote:
> how do you know? maybe there was no DNS and you never even reached the server.
> don't throw out err. it tries to say something useful.
Totally, not sure why I ate the error here but not in the other spot. Fixed to
just print err.
https://codereview.appspot.com/7314046/diff/4001/src/pkg/net/http/httptest/ex...
src/pkg/net/http/httptest/example_test.go:50: //Output: Hello, client
On 2013年02月07日 22:21:43, adg wrote:
> ditto
Done
Sign in to reply to this message.
bradfitz
https://codereview.appspot.com/7314046/diff/4002/src/pkg/net/http/httptest/example_test.go File src/pkg/net/http/httptest/example_test.go (right): https://codereview.appspot.com/7314046/diff/4002/src/pkg/net/http/httptest/example_test.go#newcode17 src/pkg/net/http/httptest/example_test.go:17: http.Error(w, r.URL.Path+": something went horribly wrong", http.StatusInternalServerError) this is ...
12 years, 11 months ago (2013年02月08日 03:51:55 UTC) #5
https://codereview.appspot.com/7314046/diff/4002/src/pkg/net/http/httptest/ex...
File src/pkg/net/http/httptest/example_test.go (right):
https://codereview.appspot.com/7314046/diff/4002/src/pkg/net/http/httptest/ex...
src/pkg/net/http/httptest/example_test.go:17: http.Error(w, r.URL.Path+":
something went horribly wrong", http.StatusInternalServerError)
this is an XSS vector, so makes for a bad example. http.Error doesn't escape
anything. Just say "something failed", or use html.EscapeString.
Sign in to reply to this message.
kisielk
Hello golang-dev@googlegroups.com, adg@golang.org, bradfitz@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 11 months ago (2013年02月08日 04:14:08 UTC) #6
Sign in to reply to this message.
bradfitz
LGTM. I'll reorder one line before I submit. On Thu, Feb 7, 2013 at 8:14 ...
12 years, 11 months ago (2013年02月08日 17:18:09 UTC) #7
LGTM.
I'll reorder one line before I submit.
On Thu, Feb 7, 2013 at 8:14 PM, <kamil.kisiel@gmail.com> wrote:
> Hello golang-dev@googlegroups.com, adg@golang.org, bradfitz@golang.org
> (cc: golang-dev@googlegroups.com),
>
> Please take another look.
>
>
>
https://codereview.appspot.**com/7314046/<https://codereview.appspot.com/7314...
>
Sign in to reply to this message.
bradfitz
*** Submitted as https://code.google.com/p/go/source/detail?r=bad13530d9b3 *** net/http/httptest: add examples R=golang-dev, adg, bradfitz CC=golang-dev https://codereview.appspot.com/7314046 Committer: Brad ...
12 years, 11 months ago (2013年02月08日 17:20:55 UTC) #8
*** Submitted as https://code.google.com/p/go/source/detail?r=bad13530d9b3 ***
net/http/httptest: add examples
R=golang-dev, adg, bradfitz
CC=golang-dev
https://codereview.appspot.com/7314046
Committer: Brad Fitzpatrick <bradfitz@golang.org>
Sign in to reply to this message.
remyoudompheng
R=close
12 years, 5 months ago (2013年07月20日 21:25:00 UTC) #9
R=close
Sign in to reply to this message.
|
This is Rietveld f62528b

AltStyle によって変換されたページ (->オリジナル) /