You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(6) |
Oct
(6) |
Nov
(8) |
Dec
(2) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(19) |
Feb
(15) |
Mar
(10) |
Apr
(8) |
May
(7) |
Jun
(9) |
Jul
(13) |
Aug
(31) |
Sep
(111) |
Oct
(52) |
Nov
(72) |
Dec
(42) |
| 2006 |
Jan
(21) |
Feb
(32) |
Mar
(33) |
Apr
(24) |
May
(15) |
Jun
(40) |
Jul
(32) |
Aug
(19) |
Sep
(38) |
Oct
(37) |
Nov
(63) |
Dec
(37) |
| 2007 |
Jan
(18) |
Feb
(39) |
Mar
(69) |
Apr
(49) |
May
(71) |
Jun
(59) |
Jul
(71) |
Aug
(85) |
Sep
(46) |
Oct
(14) |
Nov
(25) |
Dec
(56) |
| 2008 |
Jan
(24) |
Feb
(77) |
Mar
(104) |
Apr
(44) |
May
(41) |
Jun
(11) |
Jul
(31) |
Aug
(59) |
Sep
(44) |
Oct
(86) |
Nov
(66) |
Dec
(93) |
| 2009 |
Jan
(88) |
Feb
(41) |
Mar
(49) |
Apr
(135) |
May
(22) |
Jun
(31) |
Jul
(60) |
Aug
(71) |
Sep
(76) |
Oct
(18) |
Nov
(52) |
Dec
(20) |
| 2010 |
Jan
(8) |
Feb
(50) |
Mar
(35) |
Apr
(48) |
May
(46) |
Jun
(84) |
Jul
(38) |
Aug
(61) |
Sep
(51) |
Oct
(31) |
Nov
(17) |
Dec
(18) |
| 2011 |
Jan
(51) |
Feb
(14) |
Mar
(17) |
Apr
(23) |
May
(15) |
Jun
(11) |
Jul
(5) |
Aug
(5) |
Sep
(15) |
Oct
(8) |
Nov
(5) |
Dec
(25) |
| 2012 |
Jan
(2) |
Feb
(4) |
Mar
(6) |
Apr
(9) |
May
(27) |
Jun
(32) |
Jul
(36) |
Aug
(10) |
Sep
(16) |
Oct
(3) |
Nov
(13) |
Dec
(7) |
| 2013 |
Jan
(1) |
Feb
(4) |
Mar
|
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(4) |
Oct
(2) |
Nov
(1) |
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
(2) |
Apr
(1) |
May
(2) |
Jun
(9) |
Jul
(5) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
|
Dec
|
| 2015 |
Jan
(3) |
Feb
(2) |
Mar
(4) |
Apr
(3) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(2) |
Sep
(5) |
Oct
(1) |
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
(3) |
Oct
|
Nov
|
Dec
|
| 2017 |
Jan
(6) |
Feb
|
Mar
|
Apr
(10) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
| 2018 |
Jan
(2) |
Feb
(5) |
Mar
|
Apr
|
May
(1) |
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
| 2021 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2023 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
1
|
2
|
3
|
4
(2) |
5
(5) |
6
(5) |
|
7
(5) |
8
(2) |
9
(5) |
10
(2) |
11
(2) |
12
(2) |
13
|
|
14
(5) |
15
(4) |
16
|
17
(2) |
18
(4) |
19
(2) |
20
(1) |
|
21
(1) |
22
|
23
|
24
|
25
(1) |
26
|
27
|
|
28
|
|
|
|
|
|
|
|
From: <php...@li...> - 2010-02-07 17:41:38
|
> In any case, this isn't due to bugs in PHP or the PHP/Java Bridge, but > due to your misunderstanding of how HTTP chunked encoding works and what > fgets() and feof() do. I comfortably admit I am new to downloading very large files in PHP, and I'm trying to learn. I found an approach that worked...mostly. But it caused PHP to crash under JavaBridge and Tomcat. An experienced Java programmer saw the logs and said it was due to a class error. I contacted this mailing list and explained what was happening and was told that it was down to a feature not yet supported in JavaBridge. Now I'm being told it's not down to that. I don't have any understanding of HTTP chunked encoding works. I'm not using this header in my code and your references to it were the first that I had seen. I'll read up on this and see how I can use it given what you say. And looking at the implementation of chunked encoding will give me more information on how fgets() and feof() work generally, and in the context of chunked encoding. Again, many thanks for helping out. It is appreciated. Mark... |
|
From: <php...@li...> - 2010-02-07 16:48:36
|
On Sun, 2010-02-07 at 15:19 +0700, php...@li... wrote: > I'm just trying to download the response in a way How else do you want to download the files efficiently, if not via Transfer-Encoding: Chunked? > The downloads only fail 'sometimes', so I don't understand how some of > the explanations Given your code, the possibility that PHP reads "over the edge" depends on the file size. If the file is large it is more likely that this will happen. In any case, this isn't due to bugs in PHP or the PHP/Java Bridge, but due to your misunderstanding of how HTTP chunked encoding works and what fgets() and feof() do. Regards, Jost Bökemeier |
|
From: <php...@li...> - 2010-02-07 08:26:04
|
> If the data you receive is encoded in HTTP/1.1 chunks
I don't believe it is, but I don't know a lot about these things, so I
might be wrong.
There's nothing special happening at the server side. It's just a GET
request and response. I'm just trying to download the response in a way
that doesn't cause me memory problems with files that can be 100MBs in size.
At present, the code below is producing an adequate result, ie: it's not
failed in testing yet. The downloads only fail 'sometimes', so I don't
understand how some of the explanations offer here fit to what's
happening. The retry improves the chance of the downloading completing.
If a file does not complete after the retries, the client handles this,
and the downloads are retried again later.
Thanks thanks for everyone's advice though. Some of it is over my head
as a PHP newbie, but I'm understanding and learning other parts of what
is being said.
Cheers,
Mark...
$download_attempt = 1;
do {
$fs = fsockopen($host, 80, $errno, $errstr, 30);
if (!$fs) {
$this->writeDebugInfo("FAILED ", $errstr . '(' . $errno .
')');
} else {
$out = "GET $file HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fs, $out);
$fm = fopen ($temp_file_name, "w");
stream_set_timeout($fs, 30);
while(!feof($fs) && ($debug = fgets($fs)) != "\r\n" ); //
ignore headers
while(!feof($fs)) {
$contents = fgets($fs, 4096); // Chunk download
fwrite($fm, $contents);
$info = stream_get_meta_data($fs);
if ($info['timed_out']) {
break;
}
}
fclose($fm);
fclose($fs);
if ($info['timed_out']) {
// Delete temp file if fails
unlink($temp_file_name);
$this->writeDebugInfo("FAILED on attempt " .
$download_attempt . " - Connection timed out: ", $temp_file_name);
$download_attempt++;
if ($download_attempt < 5) {
$this->writeDebugInfo("RETRYING: ", $temp_file_name);
}
} else {
// Move temp file if succeeds
$media_file_name = str_replace('temp/', 'media/',
$temp_file_name);
rename($temp_file_name, $media_file_name);
$this->writeDebugInfo("SUCCESS: ", $media_file_name);
}
}
} while ($download_attempt < 5 && $info['timed_out']);
|
|
From: <php...@li...> - 2010-02-07 07:29:57
|
Hi Peter, > The apache server sends garbage if you send http 1.0 but expect http > 1.1. are we talking about this apache feature which can stream bytes to the client? This feature is quite useful on C level, you can simply read() the bytes as apache generates them. But it is difficult to handle in PHP or Bea WebLogic for example, because their network implementations use a buffer which reads data eagerly. If the PHP network buffer contains 4 bytes and fread() requests 20 bytes, PHP tries to read 16 bytes from the network, instead of simply returning the 4 bytes available so far. I don't know why PHP and other JEE servers implement their network buffers this way. It might be more efficient for normal HTTP connections, but it is bad for data packets which don't have an explicit length; in PHP you must call fread($sock, 1), if you don't want to run into a dead lock. Or you must unblock the stream and call stream_select() for each packet. Very low tech... Regards, Jost Bökemeier |
|
From: <php...@li...> - 2010-02-07 00:00:01
|
Hello!
The apache server sends garbage if you send http 1.0 but expect http 1.1.
The following code will work:
$sock = fsockopen(...);
fwrite($sock, "GET /foo.php HTTP/1.1\r\nHost: localhost\r\n\r\n");
while(fgets($sock)!="\r\n");
while($len=hexdec(fgets($sock))) {
for($str=fread($sock, $len); $len>strlen($str); $str.=fread($sock, $len-strlen($str)));
echo $str;
}
Peter
|