Skip to content

d3v-one/urlgetcontents

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

About

This is a replacement for the function file_get_contents when using an URI.

The problem with file_get_contents for URIs is that the function waits for the connection to be closed by the remote side before returning. When the connection stays open, the function runs into a connection timeout of typically 120 seconds. Normally, two possible remedies are suggested for that: sending a "Connection" header with the argument "close" or setting the connection timeout to the lowest possible value:

$context = stream_context_create(array('http' => array('header'=>'Connection: close\r\n', 'timeout' => 2)));
$content = file_get_contents($url, false, $params);

This may or may not work. The best way is obviously to parse the "Content-Length" header sent by the remote server and to close the connection when all data is received.

This replacement version does not use the "offset" or "maxlen" arguments of the original, which may very easily be added.

Author

Michael Koch d3v.one

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

A replacement for the function file_get_contents when using an URI.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages