Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Handling incoming HTTP PUT - RESUME (partial content) in cgi

by chanakya (Friar)
on Aug 23, 2010 at 05:33 UTC ( #856635=perlquestion: print w/replies, xml ) Need Help??

chanakya has asked for the wisdom of the Perl Monks concerning the following question:

At present I have a Perl cgi script which acts as a server and accepts incoming HTTP POST
requests from various clients. The cgi checks the headers for "POST" request and then reads in the data
and writes out the data in a file (this file is created as yyyymmddhhmmss.processid) at a specified location.

Now, I had to extend the cgi to also support HTTP PUT RESUME (partial content) functionality.
What this means is, the clients sending the data to the cgi will stop/terminate
the connection after a specified number of bytes.
The client can resume the partial PUT request at a later point of time, the clients will do so
until the complete data/attachment is transferred.

I have already read the rfc-2616 document regarding the "partial content" PUT.

Basically, I'm looking for suggestions on implementing the "partial content"
(a.k.a HTTP PUT RESUME ) functionality into the cgi.
Here are some of the points i've been trying to address:

* How and where do I store the partial PUT request data
* How to uniquely identify the resumed requests from the clients and completely
process the request from a given client.
* Can any of the Apache module or mod_perl help me in solving the issues.
* What settings changes need to be done in Apache.

Does anyone has sample code or suggestions about how to go about the above.

Below are the headers that I'll be receiving from the client
PUT /pups_00034326714e2364_21.7z HTTP/1.1 Cache-Control: no-store Connection: close Expect: 100-continue Host: test033S2121 User-Agent: curl/7.7.3 (i686-pc-linux-gnu) libcurl 7.7.3 (OpenSSL 0.9. +6) Content-Length: 190626 Content-Range: bytes1024-*/* Content-Type: application/x-7z-compressed

Replies are listed 'Best First'.
Re: Handling incoming HTTP PUT - RESUME (partial content) in cgi
by zentara (Archbishop) on Aug 23, 2010 at 11:40 UTC
    * How and where do I store the partial PUT request data * How to uniquely identify the resumed requests from the clients and completely process the request from a given client.

    You might want to look at CGI::Session, it stores all transactions in a database, and you probably can use that to identify resumed requests by examining the last transaction.


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku <flash japh
      You might want to look at CGI::Session, it stores all transactions in a database, and you probably can use that to identify resumed requests by examining the last transaction.

      Good idea, except that CGI::Session uses algorithms for the session ID that may cause collisions. See Re^4: Randomness encountered with CGI Session.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re: Handling incoming HTTP PUT - RESUME (partial content) in cgi
by JavaFan (Canon) on Aug 23, 2010 at 07:28 UTC
    At present I have a Perl cgi script which acts as a server
    That doesn't make any sense. CGI is a protocol between an http server and a program spawned by said server. The spawned program is known as the CGI program.

    If your program is a server, there's no second process to communicate with. There's no CGI involved.

      Hi JavaFan

      Let me rephrase my question, my cgi program processes incoming requests and is hosted on an Apache Server.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://856635]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2022-12-03 18:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?