A new web-based library for newLISP
A new web-based library for newLISP
I've written a replacement CGI library, which can optionally work side-by-side with the official CGI module, with some caveats (see the docs for details.)
It has extensive support for URL-encoding, entities, and sessions, as well as all of the functionality of the CGI module.
http://www.artfulcode.net/articles/a-be ... b-library/
It has extensive support for URL-encoding, entities, and sessions, as well as all of the functionality of the CGI module.
http://www.artfulcode.net/articles/a-be ... b-library/
-
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
- Contact:
I also added a tutorial on how to write your own session storage module:
http://www.artfulcode.net/articles/cust ... wlisp-web/
http://www.artfulcode.net/articles/cust ... wlisp-web/
-
- Posts: 608
- Joined: Mon Feb 05, 2007 1:04 am
- Location: Abbotsford, BC
- Contact:
I bet this is related to your recent re-release of the JSON module. You released your module at just the right time, I'm migrating a legacy PHP codebase to newLISP.
I'm wondering, when you parse the POST data, do you check the content type? There are two or three content types that should be url-decoded, but anything else should be left as is, and treated as a stream of raw data.
Does your module handle this?
If the POST data is an XML stream, for instance, what do I do when using your module?
Ted
I'm wondering, when you parse the POST data, do you check the content type? There are two or three content types that should be url-decoded, but anything else should be left as is, and treated as a stream of raw data.
Does your module handle this?
If the POST data is an XML stream, for instance, what do I do when using your module?
Ted
-
- Posts: 608
- Joined: Mon Feb 05, 2007 1:04 am
- Location: Abbotsford, BC
- Contact:
I was just about to post that you were wrong about MySQL being best supported in newLISP, then realized I haven't added in the support for auto-converting query return types (int, float, etc). Until that is done, I'll hold my peace. But apart from that, I think the Postgres support in newLISP is pretty damn good. :)Jeff wrote:I also added a tutorial on how to write your own session storage module:
http://www.artfulcode.net/articles/cust ... wlisp-web/
-
- Posts: 608
- Joined: Mon Feb 05, 2007 1:04 am
- Location: Abbotsford, BC
- Contact:
-
- Posts: 608
- Joined: Mon Feb 05, 2007 1:04 am
- Location: Abbotsford, BC
- Contact:
Regarding the MIME type of the POST data, I dug up some old code of mine to see what is happening. Here are the results:
If CONTENT_TYPE === application/x-www-form-urlencoded, then we url-decode.
If CONTENT_TYPE === multipart/form-data; then we have to do some mime decoding.
Once the MIME decoding is done, I don't know if we have to url-decode, presumably if one of the mime parts has a content type of x-www-form-urlencoded, then we decode it.
At all other times, the POST should be nil I guess, or at least read into a variable of some sort.
Ted
If CONTENT_TYPE === application/x-www-form-urlencoded, then we url-decode.
If CONTENT_TYPE === multipart/form-data; then we have to do some mime decoding.
Once the MIME decoding is done, I don't know if we have to url-decode, presumably if one of the mime parts has a content type of x-www-form-urlencoded, then we decode it.
At all other times, the POST should be nil I guess, or at least read into a variable of some sort.
Ted
-
- Posts: 608
- Joined: Mon Feb 05, 2007 1:04 am
- Location: Abbotsford, BC
- Contact:
-
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
- Contact:
Ted -
Sorry for taking so long to respond. I was in meetings much of yesterday and am running a bit behind.
I will work on adding the secure cookie functionality and MIME parsing of the POST body, but it may be a little while. Alas, they make me write actual code for my paycheck, like I don't have other things to attend to :)
In the meantime, if you have a patch or some ready-made code for parsing a MIME-encoded POST body, I would love to take a look at it.
Sorry for taking so long to respond. I was in meetings much of yesterday and am running a bit behind.
I will work on adding the secure cookie functionality and MIME parsing of the POST body, but it may be a little while. Alas, they make me write actual code for my paycheck, like I don't have other things to attend to :)
In the meantime, if you have a patch or some ready-made code for parsing a MIME-encoded POST body, I would love to take a look at it.
In trying to parse the MIME content, I'm having some difficulty reading the entirety of the POST data. Or perhaps outputting the entirety of the binary POST content. The problem appears to be that the binary may contain null values, and that write-buffer and read-buffer both halt when encountering nulls. Any ideas on how to work around this?
-
- Posts: 608
- Joined: Mon Feb 05, 2007 1:04 am
- Location: Abbotsford, BC
- Contact:
Hi Jeff, I've been coding for a paycheck too, sorry I haven't had time to help out with this. I can definitely see with your improvements, I'd like to see your cgi module be part of the base distro.
As for the 0 value bytes in the stream, we'll have to ask Lutz about this one. I know newlisp strings can have 0 value bytes, and there probably is a read- function that will allow it.
Just reading the description of read-buffer, it looks like a BUG in read-buffer, and it also seems like an unecessary limitation that the arg str-wait can't contain a 0 byte either.
To get it working right now, I suppose (while (setq c (read-char 0)) ...) could be used.
As for the 0 value bytes in the stream, we'll have to ask Lutz about this one. I know newlisp strings can have 0 value bytes, and there probably is a read- function that will allow it.
Just reading the description of read-buffer, it looks like a BUG in read-buffer, and it also seems like an unecessary limitation that the arg str-wait can't contain a 0 byte either.
To get it working right now, I suppose (while (setq c (read-char 0)) ...) could be used.
'read-buffer' and 'write-buffer' both handle 0 bytes and so do almost all other functions handing string buffers. Here is a demo and source for transferring files with HTTP POST:
http://www.newlisp.org/index.cgi?page=F ... oad_Script
There are few functions when used on binary content which will stop at zeros, i.e. 'string', 'print' and 'println'.
I have also used HTTP PUT to transfer binary content.
ps: there is a limitation only when using wait-string syntax for the wait-string itself
http://www.newlisp.org/index.cgi?page=F ... oad_Script
There are few functions when used on binary content which will stop at zeros, i.e. 'string', 'print' and 'println'.
I have also used HTTP PUT to transfer binary content.
ps: there is a limitation only when using wait-string syntax for the wait-string itself
-
- Posts: 608
- Joined: Mon Feb 05, 2007 1:04 am
- Location: Abbotsford, BC
- Contact:
Lutz says read-buffer and write-buffer are working, can you give us a test case and localize it to a line of code?Jeff wrote:In trying to parse the MIME content, I'm having some difficulty reading the entirety of the POST data. Or perhaps outputting the entirety of the binary POST content. The problem appears to be that the binary may contain null values, and that write-buffer and read-buffer both halt when encountering nulls. Any ideas on how to work around this?
Ted
Sure. Here is the code that reads the POST data:
I have tried various POST_LIMIT sizes, although that should not affect the outcome.
I always end up with a smaller number of bytes than (peek (device)) reports in the buffer.
Code: Select all
(let ((post "") (buffer ""))
(while (read-buffer (device) buffer POST_LIMIT)
(write-buffer post buffer))
I always end up with a smaller number of bytes than (peek (device)) reports in the buffer.
Dragonfly
Hi Jeff,
I'm very excited about Your library, so I started to write an extension called Dragonfly. It's going to be a small framework for web applications. I'm just learning the way newLISP works and posted my code thoughts into Google Code
http://code.google.com/p/dragonfly-newlisp/
But beware: it's really a version 0.01!
Best Regards from Germany
Marc
I'm very excited about Your library, so I started to write an extension called Dragonfly. It's going to be a small framework for web applications. I'm just learning the way newLISP works and posted my code thoughts into Google Code
http://code.google.com/p/dragonfly-newlisp/
But beware: it's really a version 0.01!
Best Regards from Germany
Marc
I just opened a blog about the Dragonfly web framework and updated the Roadmap on Google Code. You'll find the blog here http://dragonfly-newlisp.blogspot.com/
And Google Analytics told me, that there were the first visitors :)
And Google Analytics told me, that there were the first visitors :)
-
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
- Contact:
Dragonfly Version 0.03 is available in Google Code, including a HTML table generator and some small updates to debugging information. See this blog post how it works.
http://dragonfly-newlisp.blogspot.com/2 ... tions.html
What do You think?
Best Regards
Marc
http://dragonfly-newlisp.blogspot.com/2 ... tions.html
What do You think?
Best Regards
Marc