Hi everyone.
I'm writing a webpage downloader which downloads pages using CURL and fopen libraries. My script defines automatically which one is supported by customer's server and my script uses it automatically. I have written everything with CURL and now I want to develop a similar solution with fopen() because I want support both customers who have either fopen or curl. But I got a problem.
If I make an fopen call and a page redirects me to another location using http headers, the final url will be different than the one I requested. For example, if I request:
http://Host1.com/SomePage.html
and it redirects everyone using "302 Moved Temporarily" to
http://AnotherHost2.com/OtherPage.html
the final url obviously will be http://AnotherHost2.com/OtherPage.html but not http://Host1.com/SomePage.html.
So I will need to parse all the images at another location and moreover all pathes must be bound to another location!
Can someone tell me how can I access the http headers with fopen to define if I was redirected? If I could do it, I would simply take a look at "Location: " header and the problem would be solved. But how can I do it, how can I see http headers with fopen?
Thanks.
P.S. I do know well that CUrl allows watching http headers, but it is not a solution for me anymore. Because I need the same stuff for fopen solely.
How to get headers from fopen() call?
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: How to get headers from fopen() call?
How to do the same with php4.x? Is there any workaround?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: How to get headers from fopen() call?
You should always read the comments too:
http://www.php.net/manual/en/function.g ... .php#58295
And use Google and the PHP manual search:
http://us2.php.net/manual/en/reserved.v ... header.php
http://www.php.net/manual/en/function.g ... .php#58295
And use Google and the PHP manual search:
http://us2.php.net/manual/en/reserved.v ... header.php
(#10850)