mirror of
https://github.com/graygnuorg/pound.git
synced 2026-10-25 10:19:36 +03:00
346 lines
4.2 KiB
Plaintext
346 lines
4.2 KiB
Plaintext
# This file is part of pound testsuite. -*- autotest -*-
|
|
# Copyright (C) 2023-2026 Sergey Poznyakoff
|
|
#
|
|
# Pound is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# Pound is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with pound. If not, see <http://www.gnu.org/licenses/>.
|
|
AT_SETUP([Basic set directives])
|
|
AT_KEYWORDS([set rewrite])
|
|
PT_CHECK([ListenHTTP
|
|
Service
|
|
Rewrite
|
|
SetURL "/echo/other"
|
|
End
|
|
Backend
|
|
Address
|
|
Port
|
|
End
|
|
End
|
|
End
|
|
],
|
|
[GET /one
|
|
end
|
|
|
|
200
|
|
x-orig-uri: /echo/other
|
|
end
|
|
])
|
|
|
|
PT_CHECK([ListenHTTP
|
|
Service
|
|
Rewrite
|
|
SetPath "/echo/other"
|
|
End
|
|
Backend
|
|
Address
|
|
Port
|
|
End
|
|
End
|
|
End
|
|
],
|
|
[GET /one
|
|
end
|
|
|
|
200
|
|
x-orig-uri: /echo/other
|
|
end
|
|
])
|
|
|
|
PT_CHECK([ListenHTTP
|
|
Service
|
|
Rewrite
|
|
SetPath -encode "/echo/one&other"
|
|
End
|
|
Backend
|
|
Address
|
|
Port
|
|
End
|
|
End
|
|
End
|
|
],
|
|
[GET /one
|
|
end
|
|
|
|
200
|
|
x-orig-uri: /echo/one%26other
|
|
end
|
|
])
|
|
|
|
PT_CHECK([ListenHTTP
|
|
Service
|
|
Rewrite
|
|
SetQuery "foo=10&quux=b%20ar"
|
|
End
|
|
Backend
|
|
Address
|
|
Port
|
|
End
|
|
End
|
|
End
|
|
],
|
|
[GET /echo/one
|
|
end
|
|
|
|
200
|
|
x-orig-uri: /echo/one?foo=10&quux=b%20ar
|
|
end
|
|
])
|
|
|
|
PT_CHECK([ListenHTTP
|
|
Service
|
|
Rewrite
|
|
DeleteQuery
|
|
End
|
|
Backend
|
|
Address
|
|
Port
|
|
End
|
|
End
|
|
End
|
|
],
|
|
[GET /echo/one?foo=10&quux=b%20ar
|
|
end
|
|
|
|
200
|
|
x-orig-uri: /echo/one
|
|
end
|
|
])
|
|
|
|
PT_CHECK([ListenHTTP
|
|
Service
|
|
Rewrite
|
|
SetQueryParam "foo" "10"
|
|
SetQueryParam "quux" "b%20ar"
|
|
End
|
|
Backend
|
|
Address
|
|
Port
|
|
End
|
|
End
|
|
End
|
|
],
|
|
[GET /echo/one
|
|
end
|
|
|
|
200
|
|
x-orig-uri: /echo/one?foo=10&quux=b%20ar
|
|
end
|
|
])
|
|
|
|
PT_CHECK([ListenHTTP
|
|
Service
|
|
Rewrite
|
|
SetQueryParam -encode "quux" "foo & bar"
|
|
SetQueryParam "foo" -encode "q?"
|
|
End
|
|
Backend
|
|
Address
|
|
Port
|
|
End
|
|
End
|
|
End
|
|
],
|
|
[GET /echo/one?foo=10
|
|
end
|
|
|
|
200
|
|
x-orig-uri: /echo/one?foo=q%3F&quux=foo%20%26%20bar
|
|
end
|
|
])
|
|
|
|
PT_CHECK([ListenHTTP
|
|
Service
|
|
Rewrite
|
|
SetQueryParam "foo"
|
|
End
|
|
Backend
|
|
Address
|
|
Port
|
|
End
|
|
End
|
|
End
|
|
],
|
|
[GET /echo/one?foo=10&quux=b%20ar
|
|
end
|
|
|
|
200
|
|
x-orig-uri: /echo/one?quux=b%20ar
|
|
end
|
|
])
|
|
|
|
PT_CHECK([ListenHTTP
|
|
Service
|
|
Rewrite
|
|
SetHeader "X-Foo: bar baz"
|
|
End
|
|
Backend
|
|
Address
|
|
Port
|
|
End
|
|
End
|
|
End
|
|
],
|
|
[GET /echo/one
|
|
end
|
|
|
|
200
|
|
x-orig-header-x-foo: bar baz
|
|
end
|
|
])
|
|
|
|
PT_CHECK([ListenHTTP
|
|
Service
|
|
Rewrite
|
|
DeleteHeader -beg "X-Accept"
|
|
End
|
|
Backend
|
|
Address
|
|
Port
|
|
End
|
|
End
|
|
End
|
|
],
|
|
[GET /echo/foo
|
|
X-Accept: *
|
|
X-Accept-Ex: foo
|
|
end
|
|
|
|
200
|
|
-x-orig-header-X-Accept:
|
|
-x-orig-header-X-Accept-Ex:
|
|
end
|
|
])
|
|
|
|
PT_CHECK([ListenHTTP
|
|
Service
|
|
Rewrite
|
|
DeleteHeader -beg "X-Accept:"
|
|
End
|
|
Backend
|
|
Address
|
|
Port
|
|
End
|
|
End
|
|
End
|
|
],
|
|
[GET /echo/foo
|
|
X-Accept: *
|
|
X-Accept-Ex: foo
|
|
end
|
|
|
|
200
|
|
-x-orig-header-X-Accept:
|
|
x-orig-header-X-Accept-Ex: foo
|
|
end
|
|
])
|
|
|
|
PT_CHECK([ListenHTTP
|
|
Service
|
|
Rewrite
|
|
DeleteHeader ["X-Accept:[[:space:]]*bar"]
|
|
End
|
|
Backend
|
|
Address
|
|
Port
|
|
End
|
|
End
|
|
End
|
|
],
|
|
[GET /echo/foo
|
|
X-Accept: *
|
|
X-Accept-Ex: foo
|
|
end
|
|
|
|
200
|
|
x-orig-header-X-Accept: *
|
|
x-orig-header-X-Accept-Ex: foo
|
|
end
|
|
])
|
|
|
|
PT_CHECK([ListenHTTP
|
|
Service
|
|
Rewrite
|
|
DeleteHeader ["X-Accept:[[:space:]]*bar"]
|
|
End
|
|
Backend
|
|
Address
|
|
Port
|
|
End
|
|
End
|
|
End
|
|
],
|
|
[GET /echo/foo
|
|
X-Accept: bar
|
|
X-Accept-Ex: foo
|
|
end
|
|
|
|
200
|
|
-x-orig-header-X-Accept:
|
|
x-orig-header-X-Accept-Ex: foo
|
|
end
|
|
])
|
|
|
|
PT_CHECK([ListenHTTP
|
|
Service
|
|
Rewrite
|
|
SetPath "/echo/other"
|
|
SetQueryParam "foo" "bar"
|
|
SetQueryParam "qux" "x%2Fuq"
|
|
SetHeader "x-foo: bar baz"
|
|
DeleteHeader -beg -icase "x-bar:"
|
|
End
|
|
Backend
|
|
Address
|
|
Port
|
|
End
|
|
End
|
|
End
|
|
],
|
|
[GET /one
|
|
X-Bar: qux
|
|
end
|
|
|
|
200
|
|
x-orig-uri: /echo/other?foo=bar&qux=x%2Fuq
|
|
x-orig-header-x-foo: bar baz
|
|
-x-orig-header-X-Bar:
|
|
end
|
|
])
|
|
|
|
PT_CHECK([ListenHTTP
|
|
Service
|
|
SetPath ["/echo/other"]
|
|
SetQueryParam "foo" "bar"
|
|
SetQueryParam "qux" "x%2Fuq"
|
|
SetHeader "x-foo: bar baz"
|
|
DeleteHeader -beg -icase "x-bar:"
|
|
|
|
Backend
|
|
Address
|
|
Port
|
|
End
|
|
End
|
|
End
|
|
],
|
|
[GET /one
|
|
X-Bar: qux
|
|
end
|
|
|
|
200
|
|
x-orig-uri: /echo/other?foo=bar&qux=x%2Fuq
|
|
x-orig-header-x-foo: bar baz
|
|
-x-orig-header-X-Bar:
|
|
end
|
|
])
|
|
|
|
AT_CLEANUP
|