chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I'm starting using chicken4 (Re: [Chicken-users] 4.6.1 performance b


From: Peter Bex
Subject: Re: I'm starting using chicken4 (Re: [Chicken-users] 4.6.1 performance boost
Date: Mon, 4 Oct 2010 15:24:10 +0200
User-agent: Mutt/1.4.2.3i

On Mon, Oct 04, 2010 at 08:13:35PM +0900, Daishi Kato wrote:
> > I'm confused; do you think the eggs are lower-level than your code, or
> > do you think the spiffy code itself is low-level, or what?
> 
> OK, I meant:
> a) chicken3/http-server was low level so that I can write my handler.
> b) chicken3/spiffy was not low level.
> c) chicken4/spiffy is low level enough to port my code thanks to vhost 
> support.

I see.

> > It is, but it comes at the price of not being able to simply define
> > request handlers at the global path level, since those would apply
> > to all vhosts.
> 
> I'm not so motivated since I'm already moved to chicken4,
> but I'm happy to contribute to the community, so let me try writing it.
> 
> ;;;; raw-handler.scm
> ; handler to emulate chicken3-style request-handler

[..code snipped..]

I don't know, but that doesn't look complete.

> However, this is not compatible with chicken3/http-server,
> because of the structure of req, which is port-based instead of string-based.
> If it is required, we could make it really compatible.

Yeah, that'd just be a simple wrapper layer around it.

> How about splitting lower-level procedures and higher-level procedures?

There aren't really "levels" in uri-common. You have the various
constructors and accessors, and some utility procedures.

I moved down the conversion procedures so that the constructors and
accessors are listed first.  They're the most important procedures
anyway. I hope this helps a bit.

> I also don't understand why there are uri-generic and uri-common.
> Can it be just like uri-generic provides the structure,
> and uri-common provides processing procedures?

uri-generic is an implementation of the RFC. uri-common simply handles
the gap between what the RFC defines and how HTTP URIs are generally
used (in combination with html's uri-encoding scheme for forms)

Without uri-common you only get the really basic separation between
scheme, authority, path, query and fragment.  It doesn't provide alist
parsing of the query and such.

However, uri-generic is useful when you wish to build parsers specific
to other URI classes (for example, URNs or SMB file identifier URIs).

> > > (define (get-ref-url-from uri)
> > >   (let ([baseuri (uri-reference (sprintf "~a://~a:~a/" (uri-scheme uri) 
> > > (uri-host uri) (uri-port uri)))])
> > >     (uri->string (uri-relative-from uri baseuri))))
> > 
> > I'm not sure what the purpose of this one is, but you could do it
> > with either
> 
> I'm creating 302 response without specifying the host.

Sorry, that's not allowed (see RFC2616, 14.30).  I know, "everyone
does it", but it's actually invalid.

Anyway, why would you want to do that at all?  The current request URI
is already absolute by default, and having the host in there doesn't
hurt, does it?

I went through quite some trouble to get it working this way precisely
because of the requirement in the RFC that the location should be
absolute!  And now you're going through a lot of trouble to strip off
that stuff, undoing my work.  I find that rather ironic :)

> > > (define (get-query-from-uri uri)
> > >   (let ([query (uri-query uri)])
> > >     (and (pair? query)
> > >          (map (lambda (x) (cons (symbol->string (car x)) (cdr x)))
> > >               query))))
> > 
> > Things like this can be done easily by creating an "empty" uri reference
> > and copying over those things you need:
> > 
> > (uri->string (update-uri (uri-reference "") query: (uri-query uri)))
> 
> wow. I wish you include those examples in the doc.

It's a wiki, you know :) But I've added it for you.

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
                                                        -- Donald Knuth



reply via email to

[Prev in Thread] Current Thread [Next in Thread]