Answer the question
In order to leave comments, you need to log in
How to send your headers in CURL? (WevDav)
Greetings. Can you tell me how to send my custom headers to the server using curl?
COPY /var/www/documents/test/test.pdf HTTP/1.1
Host: localhost.ru
Destination: http://localhost.ru/test.pdf
Overwrite: F
Depth: infinity
Accept: */*
Content-type: application/xml; charset="utf-8"
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($ch, CURLOPT_USERPWD, implode(':', $credentials));
curl_setopt($ch, CURLOPT_URL,"http://localhost.ru");
$request = 'COPY /var/www/documents/test/test.pdf HTTP/1.1
Host: localhost.ru
Destination: http://localhost.ru/test.pdf
Overwrite: F
Depth: infinity
Accept: */*
Content-type: application/xml; charset="utf-8"';
$split = explode("\n",$request);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "COPY");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER,1 );
curl_setopt ($ch, CURLOPT_HTTPHEADER,$split );
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt ($ch, CURLOPT_HEADER, 1);
$dd = curl_exec($ch);
$info = curl_getinfo($ch);
HTTP/1.1 401 Authorization Required
Date: Thu, 22 May 2014 14:32:13 GMT
Server: Apache/2.2.22 (Debian)
WWW-Authenticate: Digest realm="webdav", nonce="PVee+v35BAA=09cfeb1847eab710c33f3e72be4f7a94d434bd2e", algorithm=MD5, qop="auth"
Vary: Accept-Encoding
Content-Length: 482
Content-Type: text/html; charset=iso-8859-1
HTTP/1.1 200 OK
Date: Thu, 22 May 2014 14:32:13 GMT
Server: Apache/2.2.22 (Debian)
Authentication-Info: rspauth="d5010abad112b7ad789498351dfa4146", cnonce="Mjk5OTUz", nc=00000001, qop=auth
Vary: Accept-Encoding
Content-Length: 3068
Content-Type: text/html;charset=UTF-8
Answer the question
In order to leave comments, you need to log in
Problem solved. I mistakenly thought that I would
display all the information about the sent headers. Which he doesn't do at all. If you want to see what headers curl generated and what full response it received, you need to use
$fOut = fopen($_SERVER["DOCUMENT_ROOT"].'/'.'curl_out.txt', "w" );
curl_setopt ($ch, CURLOPT_VERBOSE, 1);
curl_setopt ($ch, CURLOPT_STDERR, $fOut );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question