Having trouble with POST

0 views
Skip to first unread message

Dmitrii Dimandt

unread,
Jul 17, 2009, 4:30:31 PM7/17/09
to ew...@googlegroups.com
<form action="/login/create" method="post">
Un: <input type="text" name="un" value=""/>
<br/>
Pw: <input type="text" name="pw" value=""/>
<br/><br/>
<input type="submit" name="submit" value="Login"/>
</form>

ewgi_api:request(Ctx) yields:

{ewgi_request,undefined,39,"application/x-www-form-urlencoded",
{ewgi_spec,#Fun<ewgi_mochiweb.4.90721746>,#Fun<ewgi_mochiweb.
5.71601957>,
"http",
{1,0},
{3,
{"beep.session_id","74bd4ae7a0fca49191a5569a5a010ba86a1306da",
{"beep.controller","login_controller",
{"beep.action","create",nil,nil},
nil},
nil}}},
"EWGI/1.0",
{ewgi_http_headers,
"application/xml,application/xhtml+xml,text/html;q=0.9,text/
plain;q=0.8,image/png,*/*;q=0.5",

"__utma
=111872281.2422505602724073500.1246365803.1246451219.1246907734.3;
__utmz=111872281.1246365803.1.1.utmcsr=(direct)|utmccn=(direct)|
utmcmd=(none);
_beepbeep_session_id_=74bd4ae7a0fca49191a5569a5a010ba86a1306da",
"localhost:8000",undefined,
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us)
AppleWebKit/530.19.2 (KHTML, like Gecko) Version/4.0.2 Safari/530.19",
undefined,
{6,
{"accept-encoding",
[{'Accept-Encoding',"gzip, deflate"}],
nil,
{"accept-language",
[{'Accept-Language',"en-us"}],
nil,
{"cache-control",
[{'Cache-Control',"max-age=0"}],
nil,
{"connection",
[{'Connection',"keep-alive"}],
nil,
{"origin",
[{"Origin","http://localhost:8000"}],
nil,
{"referer",
[{'Referer',"http://localhost:8000/login/new"}],
nil,nil}}}}}}}},
"/login/create",undefined,
[],"127.0.0.1",undefined,undefined,undefined,
undefined,'POST',[],"localhost",undefined,"HTTP/1.1","MochiWeb"}

No values are passed though.


Oh, while we are at it :) How would you handle file uploads with ewgi?

filippo pacini

unread,
Jul 18, 2009, 6:48:05 AM7/18/09
to ew...@googlegroups.com
Hi Dmitrii,
this patch solves the problem:
http://github.com/filippo/ewgi/commit/f14efdfb13f96656e02544b84d4a8d162a5c902b

For file uploads there's the read_input callback. It should work
similarly to file streaming, but I've never used it.
--
Filippo Pacini

Dmitrii Dimandt

unread,
Jul 18, 2009, 6:53:26 AM7/18/09
to ew...@googlegroups.com

On Jul 18, 2009, at 1:48 PM, filippo pacini wrote:

>
> Hi Dmitrii,
> this patch solves the problem:
> http://github.com/filippo/ewgi/commit/f14efdfb13f96656e02544b84d4a8d162a5c902b
>

Thank you!


> For file uploads there's the read_input callback. It should work
> similarly to file streaming, but I've never used it.
>

Hmm... I'll let you know when I get to it :)

Hunter Morris

unread,
Jul 18, 2009, 10:40:34 AM7/18/09
to ew...@googlegroups.com
> On Jul 18, 2009, at 1:48 PM, filippo pacini wrote:
>
>>
>> Hi Dmitrii,
>> this patch solves the problem:
>> http://github.com/filippo/ewgi/commit/f14efdfb13f96656e02544b84d4a8d162a5c902b

I think it is best for this sort of request parsing to be handled by a
middleware component. Something like this should do the trick:

http://github.com/skarab/ewgi_examples/commit/f8a5451992d2b72d73749bf2432bd05afea4688f

That way, the web framework can choose where to store the parsed form
variables (in the example above, I took Fillipo's cue and store them
in REMOTE_USER_DATA, although a better place may actually be a
framework-specific variable in the extra data tree).

Dmitrii Dimandt

unread,
Jul 18, 2009, 11:44:57 AM7/18/09
to ew...@googlegroups.com

On Jul 18, 2009, at 5:40 PM, Hunter Morris wrote:

>
>> On Jul 18, 2009, at 1:48 PM, filippo pacini wrote:
>>
>>>
>>> Hi Dmitrii,
>>> this patch solves the problem:
>>> http://github.com/filippo/ewgi/commit/f14efdfb13f96656e02544b84d4a8d162a5c902b
>
> I think it is best for this sort of request parsing to be handled by a
> middleware component. Something like this should do the trick:
>
> http://github.com/skarab/ewgi_examples/commit/f8a5451992d2b72d73749bf2432bd05afea4688f
>

Hmm.... That surely does look like a lot of extra work :) However
this does provide extra flexibility...


I beliebe we should create a simple/standardized middleware to handle
simple forms and file uploads. And let developers build on that.

Hunter Morris

unread,
Jul 18, 2009, 11:54:14 AM7/18/09
to ew...@googlegroups.com
2009/7/18 Dmitrii Dimandt <dmit...@gmail.com>:

> Hmm.... That surely does look like a lot of extra work :)  However
> this does provide extra flexibility...

Unfortunately, I think it's important to maintain the flexibility at
this level of the abstraction. ewgi was originally meant just as a
specification, leaving things like parsing POST requests to the web
framework using the spec.

> I beliebe we should create a simple/standardized middleware to handle
> simple forms and file uploads. And let developers build on that.

I agree. I can start adding pieces of middleware like this to the
smak library if you are interested? What other pieces of
functionality does beepbeep need which could be handled by
standardised middleware? We talked about file uploads (content type
multipart/form-data, from RFC 2388), so that would probably be useful
as well.

Dmitrii Dimandt

unread,
Jul 19, 2009, 3:13:49 AM7/19/09
to ew...@googlegroups.com

On Jul 18, 2009, at 6:54 PM, Hunter Morris wrote:

>
> 2009/7/18 Dmitrii Dimandt <dmit...@gmail.com>:
>> Hmm.... That surely does look like a lot of extra work :) However
>> this does provide extra flexibility...
>
> Unfortunately, I think it's important to maintain the flexibility at
> this level of the abstraction. ewgi was originally meant just as a
> specification, leaving things like parsing POST requests to the web
> framework using the spec.
>

I thought about it for a while and decided that, indeed, it should be
left to the framework.



>> I beliebe we should create a simple/standardized middleware to handle
>> simple forms and file uploads. And let developers build on that.
>
> I agree. I can start adding pieces of middleware like this to the
> smak library if you are interested? What other pieces of
> functionality does beepbeep need which could be handled by
> standardised middleware?


Since I'm currently just porting Beepbeep to ewgi, I just make up
"problems" as I go along :) So far the most obvious problem was
parsing POST requests. I will push the new version today and we'll see
what else people are requesting.
Reply all
Reply to author
Forward
0 new messages