Brian "Krow" Aker (krow) wrote,
Brian "Krow" Aker
krow

myhttp_engine, read only you think? Not so!

I was asked in comments "nice, but its only read only right?".

Not true at all!

For example, lets create this table:


mysql> CREATE TABLE `website` (
-> `filename` varchar(125) NOT NULL DEFAULT '',
-> `contents` text,
-> PRIMARY KEY (`filename`)
-> ) ENGINE=HTTP DEFAULT CHARSET=latin1 CONNECTION="http://localhost/"
-> ;
Query OK, 0 rows affected (0.00 sec)


Now, lets insert a page:


mysql> insert into website VALUES ("index.txt", "This is a document on a website");
Query OK, 1 row affected (30.01 sec)


Read the page from curl:

[brian@zim ~]$ curl http://127.0.0.1/index.txt
This is a document on a website



Now from a select:

mysql> select contents from website WHERE filename="index.txt";
+---------------------------------+
| contents |
+---------------------------------+
| This is a document on a website |
+---------------------------------+
1 row in set (0.00 sec)



How about an update?

mysql> update website SET contents="Under Construction" WHERE filename="index.txt";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0



Any just to verify:

mysql> select contents from website WHERE filename="index.txt";
+--------------------+
| contents |
+--------------------+
| Under Construction |
+--------------------+
1 row in set (0.00 sec)



And finally....

mysql> delete from website WHERE filename="index.txt";
Query OK, 1 row affected (0.01 sec)

mysql> select contents from website WHERE filename="index.txt";
Empty set (0.00 sec)


So no, its not read only at all. You can use the XMLReplace syntax to update XML documents on a webserver.

I do not have SSL working yet, but that is just a hop, skip, and a jump since I know Mark got SSL working for the AWS/S3 engine. I am using http://hg.tangent.org/mod_methods to check the work (and as I said before it needs work... its a big security risk at the moment, I would need to put in few hours of time to fix this). Anyone with some basic knowledge of how to write a CGI can put together their own via:

Script METHOD /cgi_to_execute.cgi

You will need to support HEAD/GET/DELETE/PUT.

POST is mapped to PUT currently. Someone could also just fork the engine/send me patches that would integrate well, to support webdav. Right now only two fields are supported but I will fix that by have it ship XML if need be. Suggestions on XML definition would be warmly welcome. Currently each row is a document but this could be changed.

If you are playing with this, it is better to track it from http://hg.tangent.org/myhttp_engine. I'll drop a new release next week if I hack anything interesting into it over the weekend.
Subscribe
  • Post a new comment

    Error

    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 3 comments