Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion no.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ function build_multipart_data_files($delimiter, $fields, $files) {
return $data;
}

function get_base_url($parsed_url) {
$port = isset($parsed_url['port']) ? ":$parsed_url[port]" : '';
return "$parsed_url[scheme]://$parsed_url[host]$port";
}

$curl = curl_init( $url );
curl_setopt( $curl, CURLOPT_HTTPHEADER, getRequestHeaders() );
curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, true ); # follow redirects
Expand Down Expand Up @@ -143,7 +148,7 @@ function build_multipart_data_files($delimiter, $fields, $files) {
if ( !preg_match( '/^Transfer-Encoding:/i', $header ) ) {
if ( preg_match( '/^Location:/i', $header ) ) {
# rewrite absolute local redirects to relative ones
$header = str_replace($backend_url, "/", $header);
$header = str_replace(get_base_url($backend_info), '', $header);
}
else if ( preg_match( '/^set-cookie:/i', $header ) ) {
# replace original domain name in Set-Cookie headers with our server's domain
Expand Down