Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> cURL - pobieranie zdalnego pliku przez proxy
kozikowski11
post
Post #1





Grupa: Zarejestrowani
Postów: 33
Pomógł: 0
Dołączył: 16.09.2006

Ostrzeżenie: (0%)
-----


Witam, mam problem z cURL. Przedstawie sytuacje: skrypt.php ma zawarte instrukcje cURL, ktore lacza sie przez server proxy do zdalnego serwera na ktorym umieszczony jest plik. (http://server.pl/plik.ext). W efekcie server zwraca wlasnie ten plik. Mam problem, poniewaz chce zeby plik nie byl pobierany na server na ktorym umieszczony jest skrypt.php, tylko aby zwracal informacje do uzytkownika i aby to kilent pobieral bezposrednio przez server proxy. Jak to wykonac?

Pozdrawiam
kozikowski11
Go to the top of the page
+Quote Post
cycofiasz
post
Post #2





Grupa: Zarejestrowani
Postów: 711
Pomógł: 127
Dołączył: 5.07.2008
Skąd: Łódź

Ostrzeżenie: (0%)
-----


  1. curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
Go to the top of the page
+Quote Post
kozikowski11
post
Post #3





Grupa: Zarejestrowani
Postów: 33
Pomógł: 0
Dołączył: 16.09.2006

Ostrzeżenie: (0%)
-----


Wciaz cos jest nie tak.. Fragment skrpytu:

  1.  
  2.  
  3. $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
  4. $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
  5. $header[] = "Cache-Control: max-age=0";
  6. $header[] = "Connection: keep-alive";
  7. $header[] = "Keep-Alive: 300";
  8. $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
  9. $header[] = "Accept-Language: en-us,en;q=0.5";
  10. $header[] = "Pragma: "; // browsers keep this blank.
  11.  
  12. $ch=curl_init($download_url);
  13. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  14. //curl_setopt($ch, CURLOPT_TIMEOUT, 100);
  15. curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0);
  16. curl_setopt($ch, CURLOPT_PROXY, "proxy_host:port");
  17. curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
  18. curl_setopt($ch, CURLOPT_PROXYUSERPWD,'login:pass');
  19. curl_setopt($ch, CURLOPT_FAILONERROR, 1);
  20. //curl_setopt($ch, CURLOPT_HTTPHEADER,$header );
  21. curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
  22. //curl_setopt($ch, CURLOPT_NOBODY, true);
  23. curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
  24. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  25. curl_setopt($ch, CURLOPT_HEADER, true);
  26. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  27.  
  28. $output = curl_exec($ch);
  29. curl_close($ch);
  30.  
  31. header('Content-Description: File Transfer');
  32. header('Content-Type: application/octet-stream');
  33. header('Content-Disposition: attachment; filename=qwerty1');
  34. header('Content-Transfer-Encoding: binary');
  35. header('Expires: 0');
  36. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  37. header('Pragma: public');
  38. //header('Content-Length: ' . $contentLength );
  39. readfile($output);


Ew. moze jakis psuedo-streaming?

Ten post edytował kozikowski11 18.09.2011, 12:52:34
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 00:45