MCPcopy
hub / github.com/vulcand/vulcand / TestUnknownHeader

Method TestUnknownHeader

plugin/rewrite/rewrite_test.go:193–212  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

191}
192
193func (s *RewriteSuite) TestUnknownHeader(c *C) {
194 var outURL string
195 handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
196 outURL = rawURL(req)
197 w.Write([]byte("hello"))
198 })
199
200 rh, err := newRewriteHandler(handler,
201 &Rewrite{"^http://localhost/(foo)/(bar)$", `http://localhost/$1/{{.Request.Header.Get "X-Header"}}/$2`, false, false})
202 c.Assert(rh, NotNil)
203 c.Assert(err, IsNil)
204
205 srv := httptest.NewServer(rh)
206 defer srv.Close()
207
208 re, _, err := testutils.Get(srv.URL+"/foo/bar", testutils.Host("localhost"))
209 c.Assert(err, IsNil)
210 c.Assert(re.StatusCode, Equals, http.StatusOK)
211 c.Assert(outURL, Equals, "http://localhost/foo//bar")
212}
213
214func (s *RewriteSuite) TestUnknownVar(c *C) {
215 handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {

Callers

nothing calls this directly

Calls 5

CloseMethod · 0.95
rawURLFunction · 0.85
newRewriteHandlerFunction · 0.85
WriteMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected