[perl #34121] [NEW] imc http server

1 view
Skip to first unread message

Markus Amslser

unread,
Feb 12, 2005, 7:41:56 PM2/12/05
to bugs-bi...@rt.perl.org
# New Ticket Created by Markus Amslser
# Please include the string: [perl #34121]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=34121 >


Now it's getting funny. I have written a tiny webserver in imc, that can
serve the parrot html documentation. That's also a pretty good test for
the NET_DEVEL and file readings functions. I tested it on win32, so no
idea what happens on unix.
The attached file should be placed in examples/io (no idea how to create
a /dev/null patch on win32!).

This patch depends of course on #34120.

have fun

Markus

httpd.imc

Leopold Toetsch

unread,
Feb 14, 2005, 5:57:25 AM2/14/05
to perl6-i...@perl.org
Markus Amslser <parrotbug...@parrotcode.org> wrote:

Applied 34117, 34120, 34121, 34126 in a bunch.

> Now it's getting funny. I have written a tiny webserver in imc, that can
> serve the parrot html documentation.

Great, thanks. Some remarks:
- served line endings should by "\r\n": lynx doesn't work with "\n" only
- reading html files should used the C<stat> opcode to determine the
file size

While at socket IO:

- all the current socket opcodes should be available as ParrotIO methods,
e.g.

METHOD PMC* socket(...) {...}
METHOD INTVAL bind(STRING *address) {...}

so that:

pio = getclass "ParrotIO"
sock = pio."socket"(.PIO_SOCK_FAM_PF_INET, \
.PIO_SOCK_TYPE_SOCK_STREAM, \
.PIO_SOCK_PROTO_IP)

res = sock."bind"(address)

works.

- patches welcome to allow constants for the C<socket> opcode's "magic
numbers". See: config/gen/parrot_include.pl and the &gen_from_*
directives.
The enums should be attached to the C<socket> method.

leo

Bernhard Schmalhofer via RT

unread,
Apr 30, 2005, 8:41:20 AM4/30/05
to perl6-i...@perl.org
> [leo - Mo 14. Feb 2005, 02:59:47]:

>
> Markus Amslser <parrotbug...@parrotcode.org> wrote:
> > Now it's getting funny. I have written a tiny webserver in imc, that can
> > serve the parrot html documentation.
>
> Great, thanks. Some remarks:
> - served line endings should by "\r\n": lynx doesn't work with "\n" only
This has already been fixed

> - reading html files should used the C<stat> opcode to determine the
> file size
TODO

> While at socket IO:
>
> - all the current socket opcodes should be available as ParrotIO methods,
> e.g.
>
> METHOD PMC* socket(...) {...}
> METHOD INTVAL bind(STRING *address) {...}
>
> so that:
>
> pio = getclass "ParrotIO"
> sock = pio."socket"(.PIO_SOCK_FAM_PF_INET, \
> .PIO_SOCK_TYPE_SOCK_STREAM, \
> .PIO_SOCK_PROTO_IP)
>
> res = sock."bind"(address)
>
> works.

TODO

> - patches welcome to allow constants for the C<socket> opcode's "magic
> numbers". See: config/gen/parrot_include.pl and the &gen_from_*
> directives.
> The enums should be attached to the C<socket> method.

TODO

Propably due to recent charset changes, I found that httpd.imc was no
longer working under Linux. The op 'recv' seems to return a 'binary'
string. However for 'binary' the 'index' op is not implemented, thus
httpd.imc can't check for "\r\n\r\n".

I don't know how to transcode a 'binary' to 'ascii'. Therefore
I made a dirty hack, telling PIO_unix_recv to return an 'ascii' string.


--
/* Bernhard.S...@gmx.de */

Leopold Toetsch

unread,
May 1, 2005, 5:09:54 AM5/1/05
to parrotbug...@parrotcode.org, perl6-i...@perl.org
Bernhard Schmalhofer via RT <parrotbug...@parrotcode.org> wrote:

> Propably due to recent charset changes, I found that httpd.imc was no
> longer working under Linux. The op 'recv' seems to return a 'binary'
> string. However for 'binary' the 'index' op is not implemented, thus
> httpd.imc can't check for "\r\n\r\n".

Ah yep. Ok. We can do any cobination of:
* create an "ascii" IO layer
* implement binary index
* create ascii string is the first place
* implement to_charset for binary

leo

Reply all
Reply to author
Forward
0 new messages