Skip to content

Commit f0f3bb6

Browse files
committed
Release 0.0.2
1 parent 74ebde8 commit f0f3bb6

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/index.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/* config */
34
$dest_host = "example.com"; //Destination domain
45
$proxied_headers = array('Set-Cookie', 'Content-Type', 'Cookie', 'Location'); // server -> client
@@ -12,6 +13,8 @@
1213
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1314
curl_setopt($ch, CURLOPT_HEADER, 1);
1415
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
16+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
17+
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
1518

1619
/* headers */
1720
if(isset($_SERVER['HTTP_COOKIE'])){
@@ -25,25 +28,34 @@
2528

2629
$res = curl_exec($ch);
2730

31+
2832
curl_close($ch);
2933
/* parse response */
3034
list($headers, $body) = explode("\r\n\r\n", $res, 2);
35+
3136
$headers = explode("\r\n", $headers);
3237
$hs = array();
3338
foreach($headers as $header){
3439
if(false !== strpos($header, ':')){
3540
list($h, $v) = explode(':', $header);
36-
$hs[$h] = $v;
41+
$hs[$h][] = $v;
3742
} else {
38-
$header1 = $header;
43+
$header1 = $header;
3944
}
4045
}
4146

4247
/* set headers */
43-
header($header1);
48+
list($proto, $code, $text) = explode(' ', $header1);
49+
header($_SERVER['SERVER_PROTOCOL'].' '.$code.' '.$text);
4450
foreach($proxied_headers as $hname){
4551
if(isset($hs[$hname])){
46-
header($hname.": ".$hs[$hname]);
52+
foreach($hs[$hname] as $v){
53+
if($hname === 'Set-Cookie'){
54+
header($hname.": ".$v, false);
55+
}else{
56+
header($hname.": ".$v);
57+
}
58+
}
4759
}
4860
}
4961

0 commit comments

Comments
 (0)