Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] Problem z parsowaniem nagłówka
Forum PHP.pl > Forum > Przedszkole
1q2w3e4r
Witam,

Mam problem z pobieraniem z prasowaniem nagłówka.
Gdy pobieram curlem nagłówek to zwraca mi taki kod:
  1.  
  2. HTTP/1.1 302 Moved Temporarily
  3.  
  4. Server: nginx
  5.  
  6. Date: Sat, 24 Sep 2011 16:28:57 GMT
  7.  
  8. Content-Type: text/html
  9.  
  10. Location: [url="http://www.strona.pl/plik.rar"]http://www.strona.pl/plik.rar[/url]
  11.  
  12.  
  13.  
  14. HTTP/1.1 302 Moved Temporarily
  15.  
  16. Server: nginx
  17.  
  18. Date: Sat, 24 Sep 2011 16:28:57 GMT
  19.  
  20. Content-Type: text/html
  21.  
  22. Expires: Thu, 19 Nov 1981 08:52:00 GMT
  23.  
  24. Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  25.  
  26. Pragma: no-cache
  27.  
  28. Location: [url="http://www.strona.pl/plik.rar?1679708191/4e7e0549/641e501f/8be5d5/2/3e4bdb23/0/3898219820ec797552ee7177b1d5f9feaea1cbe8"]http://www.strona.pl/plik.rar?1679708191/4...1d5f9feaea1cbe8[/url]
  29.  
  30.  
  31.  
  32. HTTP/1.1 206 Partial Content
  33.  
  34. Server: nginx
  35.  
  36. Date: Sat, 24 Sep 2011 16:28:58 GMT
  37.  
  38. Content-Type: "application/octet-stream"
  39.  
  40. Content-Length: 101
  41.  
  42. Connection: close
  43.  
  44. Content-Disposition: attachment; filename="plik.rar"
  45.  
  46. Expires: 0
  47.  
  48. Content-Range: bytes 0-100/1073741
  49.  


Wcześniej nie było przekierowania więc link Location pobierało mi dobrze bo był tylko jeden. I pobierałem go tak:
  1. if(!preg_match('|Location: ([ a-z0-9.%:/\-_()!@#$%&*\[\]{}]+)|is', $result, $matches))
  2. {
  3. return false;
  4. }
  5. $link = $matches[1];

No i tym sposobem pobiera tylko 1 Location i zwraca:
  1. (
  2. [0] => Location: [url="http://www.strona.pl/plik.rar"]http://www.strona.pl/plik.rar[/url]
  3. [1] => [url="http://www.strona.pl/plik.rar"]http://www.strona.pl/plik.rar[/url]
  4. )


Jak zrobić, aby pobierało do tablicy wszystkie Location oraz wybierać zawsze ostatni?
CuteOne
preg_match_all ?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.