Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

mdillon gave this source code a deeper look and complained about the documentation or, more exact, the lack thereof. So I write this node to document the features of the above server a bit, that all of you might play with it.

Purpose

This httpd server saw light as a proof-of-concept server for a database with highly volatile data. Such data was mostly read-only access from for example the status of the dial-up connection or the calling-party number. It was assumed that no locking of entries would be necessary as there would be only one defined writer for each node and rapid updating would be always possible.

Command set

The command set was more or less oriented at what http 1.1 provided, but also allows for server-side notification of clients so that constant polling would be unnecessary.

GET itemname
Gets an item. This format allows even a normal HTML browser to view the data.
Example
GET HELP
or, if you want a list of all available items, use

GET KEYS

SET itemname
Sets data for an item. You must supply the Content-Length: in the request and then send the data after it Example
SET TEST 123456
or, if you want to store multi-line data

SET TEST
Content-Length:10
abc
defgh

UNSET itemname
Erases an item. Pooof. Some items, notably those whose name is in the %Readonly hash, cannot be erased except through a direct Perl statement.
Example
UNSET TEST

BYE
Closes the connection.

DIE
Causes the server to die, losing all data.

RESTART
Causes the server to exec itself, losing all data.

CLONE
Causes the server to save all data to a file and then restart itself from that file, thus preserving all data.

SOURCE itemname
Executes the Perl code stored in itemname and returns what the code returned. This is a major security hole but very convenient if you want to add highly dynamic items to the server on the fly.
Example (courtesy of mdillon)

SET passwd `cat /etc/passwd`
SOURCE passwd

The purpose of this command was to faciliate populating the %Status hash with new code, like the code for the KEYS item or the WHO item. Example

SET code
Content-Length: ??? <-- fix this
sub return_test{
  return join(" ", keys %SpecialHash );
};
$Status{test} = \&return_test;
This would add a new item, test, that executes the code stored in &return_test every time the item is requested.


In reply to Push HTTP server documentation by Corion
in thread Push HTTP server by Corion

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (1)
    As of 2014-07-13 02:06 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      When choosing user names for websites, I prefer to use:








      Results (245 votes), past polls