Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Good method to pass files throught perl/cgi script ?

by Martin90 (Sexton)
on Jul 11, 2013 at 10:17 UTC ( #1043683=note: print w/replies, xml ) Need Help??


in reply to Re: Good method to pass files throught perl/cgi script ?
in thread Good method to pass files throught perl/cgi script ?

No, what I am doing is very server-related. I want to have content on my server since I have my own music player + statistic of downloaded files. ALso I would like to control if files was downloaded completely + need to control download speed and so on. So, if I use nginx along with apache and pass files thru nginx with XSendfile, would it help much ? Maybe there are other options ?
  • Comment on Re^2: Good method to pass files throught perl/cgi script ?

Replies are listed 'Best First'.
Re^3: Good method to pass files throught perl/cgi script ?
by thomas895 (Chaplain) on Jul 11, 2013 at 23:24 UTC

    As far as I know, you can't control or even see the download speed in a CGI program. Your script just reads and outputs the whole file to STDOUT, which the server then just passes along to the client. The server probably buffers it, too, so the time it took for the file to be output does not necessarily have to be the time it really took to download. Sendfile won't tell you that, either.

    As far as statistics go, you can write or use a logfile analyser, then count how many times each file was downloaded and by whom, etc.
    Fun fact: you can also add query parameters to the static file locations, and most webservers will not do anything with them by default. Use this to add extra info that you might want to analyse later.

    ~Thomas~ 
    "Excuse me for butting in, but I'm interrupt-driven..."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043683]
help
Chatterbox?
[Corion]: You'll have to look somewhere esoteric for that. Maybe some tied variable or special dualvar can also trigger that. But it's certainly not a common occurrence
[Corion]: And on 5.20, the following also outputs no find:perl -wle 'for my $x ("\x{2000}".."\ x{1fffff}") { if( $x && ! length $x ) { warn qq(<$x>); warn length $x; die } }'
[Corion]: (this time on Unix)
[hippo]: Understood. I'll have to go through the code and see if it's doing anything fancy with ties, dual-vars or non-scalars. In the end, it's probably a bug though.
[Corion]: Aaah - you should be able to do this with overload, but I would hit somebody really hard if they constructed objects that are true but the empty string, and you not knowing about the domain knowledge where this makes sense
[Eily]: you could tie a variable into not having the same value each time, if you like to make people who try to debug your code facepalm
[Corion]: perl -wle 'package o; use overload q("") => sub {warn "str"; ""}, bool => sub{warn "bool"; 1}; package main; my $o={}; bless $o => o; print "Yay" if ($o && !length($o))'
[Corion]: But people writing such code should document the objects they construct and why it makes sense for an object to be invisible as string while being true in a boolean context

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (14)
As of 2017-07-27 13:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (413 votes). Check out past polls.