Skip to content

Commit 848b99b

Browse files
committed
Merge branch 'js/http-custom-headers'
Update tests for "http.extraHeaders=<header>" to be portable back to Apache 2.2 (the original depended on <RequireAll/> which is a more recent feature). * js/http-custom-headers: submodule: ensure that -c http.extraheader is heeded t5551: make the test for extra HTTP headers more robust tests: adjust the configuration for Apache 2.2
2 parents fd704b1 + 0bbe731 commit 848b99b

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

t/lib-httpd/apache.conf

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ Alias /auth/dumb/ www/auth/dumb/
103103
Header set Set-Cookie name=value
104104
</LocationMatch>
105105
<LocationMatch /smart_headers/>
106-
<RequireAll>
107-
Require expr %{HTTP:x-magic-one} == 'abra'
108-
Require expr %{HTTP:x-magic-two} == 'cadabra'
109-
</RequireAll>
110106
SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
111107
SetEnv GIT_HTTP_EXPORT_ALL
112108
</LocationMatch>
@@ -136,6 +132,18 @@ RewriteRule ^/ftp-redir/(.*)$ ftp://localhost:1000/$1 [R=302]
136132
RewriteRule ^/loop-redir/x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-(.*) /$1 [R=302]
137133
RewriteRule ^/loop-redir/(.*)$ /loop-redir/x-$1 [R=302]
138134

135+
# Apache 2.2 does not understand <RequireAll>, so we use RewriteCond.
136+
# And as RewriteCond does not allow testing for non-matches, we match
137+
# the desired case first (one has abra, two has cadabra), and let it
138+
# pass by marking the RewriteRule as [L], "last rule, do not process
139+
# any other matching RewriteRules after this"), and then have another
140+
# RewriteRule that matches all other cases and lets them fail via '[F]',
141+
# "fail the request".
142+
RewriteCond %{HTTP:x-magic-one} =abra
143+
RewriteCond %{HTTP:x-magic-two} =cadabra
144+
RewriteRule ^/smart_headers/.* - [L]
145+
RewriteRule ^/smart_headers/.* - [F]
146+
139147
<IfDefine SSL>
140148
LoadModule ssl_module modules/mod_ssl.so
141149

t/t5551-http-fetch-smart.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,20 @@ test_expect_success EXPENSIVE 'http can handle enormous ref negotiation' '
283283
'
284284

285285
test_expect_success 'custom http headers' '
286-
test_must_fail git fetch "$HTTPD_URL/smart_headers/repo.git" &&
286+
test_must_fail git -c http.extraheader="x-magic-two: cadabra" \
287+
fetch "$HTTPD_URL/smart_headers/repo.git" &&
287288
git -c http.extraheader="x-magic-one: abra" \
288289
-c http.extraheader="x-magic-two: cadabra" \
289-
fetch "$HTTPD_URL/smart_headers/repo.git"
290+
fetch "$HTTPD_URL/smart_headers/repo.git" &&
291+
git update-index --add --cacheinfo 160000,$(git rev-parse HEAD),sub &&
292+
git config -f .gitmodules submodule.sub.path sub &&
293+
git config -f .gitmodules submodule.sub.url \
294+
"$HTTPD_URL/smart_headers/repo.git" &&
295+
git submodule init sub &&
296+
test_must_fail git submodule update sub &&
297+
git -c http.extraheader="x-magic-one: abra" \
298+
-c http.extraheader="x-magic-two: cadabra" \
299+
submodule update sub
290300
'
291301

292302
stop_httpd

0 commit comments

Comments
 (0)