Bogdan Burym
Bogdan Burym

Reputation: 5512

HTTP request with web auth and port

I need to perform a request to the following URL:

http://[USERNAME]:[PASSWORD]@[SERVER_IP]:[PORT]/some/path/to/some/file

BUT the finally generated URL is treated as INVALID because it contains the ':' character twice. Is there any solution?

That is what I tried:

$process = curl_init('http://[SERVER_IP]:[PORT]/OpenKM/webdav/okm:personal/somefile.mp4');
curl_setopt($process, CURLOPT_HEADER, 1);
curl_setopt($process, CURLOPT_USERPWD, "[USERNAME]:[PASSWORD]");
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_POST, 1);
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
$return = curl_exec($process);  // $return is FALSE
var_dump(curl_error($process));die();  // Here we see string(23) "Empty reply from server"

Upvotes: 1

Views: 742

Answers (1)

Hignesh Hirani
Hignesh Hirani

Reputation: 1049

Put encoded value of ':' instead, %3A

I suggest you to user URL Encoder tools widely available online, check one of them here...

http://meyerweb.com/eric/tools/dencoder/

Also here is complete char encoding list provided by w3school...

http://www.w3schools.com/tags/ref_urlencode.asp

Upvotes: 6

Related Questions