MCPcopy
hub / github.com/vulcand/vulcand / TestRewritePreserveQuery

Method TestRewritePreserveQuery

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

Source from the content-addressed store, hash-verified

230}
231
232func (s *RewriteSuite) TestRewritePreserveQuery(c *C) {
233 var outURL string
234 handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
235 outURL = rawURL(req)
236 w.Write([]byte("hello"))
237 })
238
239 rh, err := newRewriteHandler(handler, &Rewrite{"^http://localhost/foo(.*)", "http://localhost$1", false, false})
240 c.Assert(rh, NotNil)
241 c.Assert(err, IsNil)
242
243 srv := httptest.NewServer(rh)
244 defer srv.Close()
245
246 re, _, err := testutils.Get(srv.URL+"/foo/bar?a=b", testutils.Host("localhost"))
247 c.Assert(err, IsNil)
248 c.Assert(re.StatusCode, Equals, http.StatusOK)
249 c.Assert(outURL, Equals, "http://localhost/bar?a=b")
250}
251
252func (s *RewriteSuite) TestRewriteInQuery(c *C) {
253 var outURL string

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