You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Net::Google::Drive::Simple's download() method uses LWP::UserAgent's request() method to obtain the data. I wonder if your version of it does the right thing for Win32, which is set the file descriptor to write the response data to to binmode(). Can you check that your version of LWP::Protocol has a collect() method that uses bindmode( $fh ) after opening the response file?
On Sun Mar 23 02:03:31 2014, fjjmarques@free.fr wrote:
> there indeed seems to be such a
> binmode. Tell me if you need further details.
You can test this out yourself with a snippet of code like
#!/usr/local/bin/perl -w
use strict;
use LWP::UserAgent;
use HTTP::Request::Common;
my $ua = LWP::UserAgent->new();
my $req = GET "http://news.yahoo.com";
my $resp = $ua->request( $req, "test" );
print $resp->code(), "\n";
If the test file "test" after this is less than about 2K in size, the problem is with LWP::UserAgent.
On Sun Mar 23 16:30:16 2014, MSCHILLI wrote:
> my $req = GET "http://news.yahoo.com";
Actually, since your files seem to be truncated at 5.5k, try something bigger, like
http://files.dlink.com.au/Products/DP-301U/Manuals/DP-301U_B2_Manual_v3.10.pdf
which has 5MB.
On Mon Mar 24 15:58:03 2014, fjjmarques@free.fr wrote:
> Thank you for the test snippet. I ran it and got a 5313 ko "test" pdf
> file.
I interpreted the above to say that you downloaded the 5MB file and got 5k. Is this not the case?
On Tue Mar 25 03:07:59 2014, fjjmarques@free.fr wrote:
> No, as mentioned before the file I received was 5313 kilobytes in
> size,
Oh, I see "and got a 5313 ko 'test' pdf file" means 5MB :).
In this case, it seems LWP works OK on your platform, but for some reason Google Drive is not giving you what you expect. Are you sure those files are intact on the server? Have you used and verified them using a different client?
> In this case, it seems LWP works OK on your platform
Also, can you run your Simple.pm script on a different platform (like Mac or Linux) to verify that your platform or perl core isn't the problem?
On Tue Mar 25 17:37:11 2014, fjjmarques@free.fr wrote:
> I don't think this would solve the problem in any way. I have no doubt
> that Simple.pm does run as expected in a given context
You're mistaken, I just wanted to verify if the problem is platform/installation specific, if it has to do with your google account, or if the adapted script (would you mind posting it, btw with the secrets removed?) is doing anything unsupported.
I have no way of accessing your Google account, don't have access to your platform, and therefore can't reproduce your problem. You trying it on a different platform would rule out several possible issues.
> The analogy may not be very well chosen, but if a take say a pair of
> shoes that are not fit to me, are my feet the problem or are the shoes
It depends, what if you wanted to wear ski boots on the beach? :)
On Wed Mar 26 00:09:27 2014, fjjmarques@free.fr wrote:
> 2 - download the files with curl as follows:
> curl -Sv -H "Authorization: Bearer $access_token"
So, the question is, what is different in the request object between the curl call and the LWP::UserAgent call?
The latter you can find out by adding "$DB::single = 1;" to Simple.pm like this:
my $req = HTTP::Request->new(
GET => $url,
HTTP::Headers->new( Authorization =>
"Bearer " . $self->{ cfg }->{ access_token })
);
$DB::single = 1;
my $ua = LWP::UserAgent->new();
my $resp = $ua->request( $req, $local_file );
and then run the script in the debugger and print out the request object:
perl -d scriptname
DB<1> c
xyz.pdf ([y]/n) [y]> y
Downloading lme-2013-12-snp.pdf
Net::Google::Drive::Simple::download(lib/Net/Google/Drive/Simple.pm:455):
455: my $ua = LWP::UserAgent->new();
DB<1> x $req
0 HTTP::Request=HASH(0x7ffd6ab8d318)
'_content' => ''
'_headers' => HTTP::Headers=HASH(0x7ffd6ab8ea48)
...
Another thing you might want to try is use the download() method without a filename in the script: Replace
my $c = $gd->download( $file, $name );
by
my $data = $gd->download( $file );
and then print
print "data length: ", length( $data ), "\n";
to figure out how many bytes have been downloaded.
On Wed Mar 26 00:09:27 2014, fjjmarques@free.fr wrote:
> One question, if I may: on what platform(s) and with wich perl version
> did you test Simple.pm?
It's in use on various platforms, and personally I've tested it on Linux and Mac OSX with perl-5.16.
I haven't tried your latest suggestions yet, but I did a quick test of
the "file-download" script with Perl 5.14.2 on Linux Mint 16 Petra,
running "live" from an usb key.
For the moment I get:
Failed with 400: Bad Request at
/usr/local/share/perl/5.14.2/Net/Google/Drive/Simple.pm line 529.
No luck!
On 26/03/2014 19:35, Michael_Schilli via RT wrote:
> <URL: https://rt.cpan.org/Ticket/Display.html?id=93913 >
>
> On Wed Mar 26 00:09:27 2014, fjjmarques@free.fr wrote:
>> 2 - download the files with curl as follows:
>> curl -Sv -H "Authorization: Bearer $access_token"
> So, the question is, what is different in the request object between the curl call and the LWP::UserAgent call?
>
> The latter you can find out by adding "$DB::single = 1;" to Simple.pm like this:
>
> my $req = HTTP::Request->new(
> GET => $url,
> HTTP::Headers->new( Authorization =>
> "Bearer " . $self->{ cfg }->{ access_token })
> );
>
> $DB::single = 1;
>
> my $ua = LWP::UserAgent->new();
> my $resp = $ua->request( $req, $local_file );
>
> and then run the script in the debugger and print out the request object:
>
> perl -d scriptname
> DB<1> c
> xyz.pdf ([y]/n) [y]> y
> Downloading lme-2013-12-snp.pdf
> Net::Google::Drive::Simple::download(lib/Net/Google/Drive/Simple.pm:455):
> 455: my $ua = LWP::UserAgent->new();
> DB<1> x $req
> 0 HTTP::Request=HASH(0x7ffd6ab8d318)
> '_content' => ''
> '_headers' => HTTP::Headers=HASH(0x7ffd6ab8ea48)
> ...
>
> Another thing you might want to try is use the download() method without a filename in the script: Replace
>
> my $c = $gd->download( $file, $name );
>
> by
>
> my $data = $gd->download( $file );
>
> and then print
>
> print "data length: ", length( $data ), "\n";
>
> to figure out how many bytes have been downloaded.
On Wed Mar 26 19:34:53 2014, fjjmarques@free.fr wrote:
> Failed with 400: Bad Request at
> /usr/local/share/perl/5.14.2/Net/Google/Drive/Simple.pm line 529.
Completely different issue, most likely related to an invalid access token.
Perfectly right. I hadn't noticed that the credentials I had this time
were for "offline access" only!
The Google "developer's console" is not always extremely clear, and
receiving a generic 400 instead of a 401 somewhat confused me.
With the appropriate credentials, file downloading is now working fine
for me using Perl 5.14.2 on Mint. So now I guess we could indeed say
there is some kind of "sky shoes on a beach" problem attached to
Simple.pm and/or Windows with perl - depending on the perspective :-)
I wouldn't be suprised to find in the end that some quotes or similar
were missing somewhere.
Five minutes ago I had the suprise to see that a (very simple) script
running on Windows-Msys bash needed some modification to run on Mint,
for example. As I said, I'm (very) far from being an experienced programmer.
Well, At least I can now go make myself something to eat before
returning to Windows and meet the perl debugger.
On 26/03/2014 23:52, Michael_Schilli via RT wrote:
> <URL: https://rt.cpan.org/Ticket/Display.html?id=93913 >
>
> On Wed Mar 26 19:34:53 2014, fjjmarques@free.fr wrote:
>> Failed with 400: Bad Request at
>> /usr/local/share/perl/5.14.2/Net/Google/Drive/Simple.pm line 529.
> Completely different issue, most likely related to an invalid access token.
On Wed Mar 26 21:22:48 2014, fjjmarques@free.fr wrote:
> With the appropriate credentials, file downloading is now working fine
> for me using Perl 5.14.2 on Mint.
Nice, we're getting closer! Don't forget to try the other thing I've suggested in the previous post, namely using the download() method without specifying a file name, gobbling up the incoming bytes in a scalar and measuring its length.
On Thu Mar 27 19:44:29 2014, fjjmarques@free.fr wrote:
> downloading, however nothing is written to my hard disc.
Yes, that's correct, without the file parameter, it won't write to the disk, the data stays in memory, and the length() call verified that the downloaded size is correct.
So, it seems that somehow on Strawberry perl 5.18 on Win32 there's a problem writing binary data to disk, even while using the binary() switch as required on Win32. I'm quite surprised to see that, since you have confirmed early on that downloading a PDF file with LWP::UserAgent worked fine with the correct byte count. Can you put one of the files that you've tested this with onto a web server and then run the LWP::UserAgent test you did early on again? Something must be missing here.
On Sat Mar 29 19:41:53 2014, fjjmarques@free.fr wrote:
> files from Google and then from Box.com, which uses a similar
> authentication system (the header must also include an "Authorization:
> Bearer $access_token" string). No problem with perl 5.16. However with
> Strawberry perl 5.18, the files downloaded from Google are approx. 5
> kb,
That's quite an interesting find, I wouldn't have suspected that the request header has any effect on the truncation of the response.
The text was updated successfully, but these errors were encountered:
@fjjmarques this bug report is pretty old and seem specific to your config,
are you still experiencing this problem?
otherwise I think we should close this one for now
Migrated from rt.cpan.org#93913 (status was 'open')
Requestors:
Attachments:
From fjjmarques@free.fr on 2014-03-17 02:05:35
:
From mschilli@cpan.org on 2014-03-17 05:08:36
:
From fjjmarques@free.fr on 2014-03-23 06:03:31
:
From mschilli@cpan.org on 2014-03-23 20:30:16
:
From mschilli@cpan.org on 2014-03-23 20:36:52
:
From fjjmarques@free.fr on 2014-03-24 19:58:03
:
From mschilli@cpan.org on 2014-03-25 02:31:43
:
From fjjmarques@free.fr on 2014-03-25 06:47:57
:
From mschilli@cpan.org on 2014-03-25 06:58:37
:
From fjjmarques@free.fr on 2014-03-25 07:07:59
:
From fjjmarques@free.fr on 2014-03-25 07:11:38
:
From mschilli@cpan.org on 2014-03-25 19:51:56
:
From mschilli@cpan.org on 2014-03-25 19:55:10
:
From fjjmarques@free.fr on 2014-03-25 21:37:11
:
From fjjmarques@free.fr on 2014-03-25 21:41:13
:
From mschilli@cpan.org on 2014-03-26 01:53:26
:
From fjjmarques@free.fr on 2014-03-26 04:09:27
:
From mschilli@cpan.org on 2014-03-26 19:35:11
:
From mschilli@cpan.org on 2014-03-26 19:36:49
:
From fjjmarques@free.fr on 2014-03-26 23:34:53
:
From mschilli@cpan.org on 2014-03-26 23:52:58
:
From fjjmarques@free.fr on 2014-03-27 01:22:48
:
From mschilli@cpan.org on 2014-03-27 04:45:26
:
From fjjmarques@free.fr on 2014-03-27 23:44:29
:
From fjjmarques@free.fr on 2014-03-28 06:06:11
:
From fjjmarques@free.fr on 2014-03-28 06:36:17
:
From mschilli@cpan.org on 2014-03-28 19:20:16
:
From fjjmarques@free.fr on 2014-03-29 23:41:53
:
From fjjmarques@free.fr on 2014-03-30 08:54:33
:
From mschilli@cpan.org on 2014-03-31 04:18:45
:
The text was updated successfully, but these errors were encountered: