[TYPO3-core] RFC: Various improvements to t3lib_div::getURL
Michael Stucki
michael at typo3.org
Sat Feb 18 12:44:54 CET 2006
Hi Bernhard,
> Michael Stucki wrote:
>
>> + while (!feof($fp)) {
>> + $line = fgets ($fp,2048);
>> + $content.=$line;
> > + if ($includeHeader==2 && !strlen(trim($line))) { break; } // Stop
> > at the first empty line (= end of header)
>
> Here is some flag needed which adds only the content (skips the header)
> when includeHeader == 0.
>
> Currently the header will get returned all the time.
No, because this part is wrapped in an if() clause:
+ } elseif ($includeHeader) {
+ $parsedURL = parse_url($url);
+ if (!t3lib_div::inList('ftp,ftps,http,https,gopher,telnet', $parsedURL['scheme'])) { return false; }
+
+ $fp = fsockopen ($parsedURL['host'], ($parsedURL['port']>0 ? $parsedURL['port'] : 80), $errno, $errstr, $timeout=2);
+ if (!$fp) { return false; }
+
+ $msg = 'GET '.$parsedURL['path'].($parsedURL['query'] ? '?'.$parsedURL['query'] : '')." HTTP/1.0\r\nHost: ".$parsedURL['host']."\r\n\r\n";
+ fputs ($fp, $msg);
+ while (!feof($fp)) {
+ $line = fgets ($fp,2048);
+ $content.=$line;
+ if ($includeHeader==2 && !strlen(trim($line))) { break; } // Stop at the first empty line (= end of header)
+ }
+ fclose ($fp);
Michael
--
Use a newsreader! Check out
http://typo3.org/community/mailing-lists/use-a-news-reader/
More information about the TYPO3-team-core
mailing list