View mode: basic / threaded / horizontal-split · Log in · Help
February 03, 2012
D FCGI
Hello everybody,

Before I essentially spam everybody, I'll introduce myself. I am James
Miller, and English developer living in New Zealand, I started using D
about 2 months ago and am currently working on a large project using
it.

As part of that project, I developed a FastCGI library (mostly because
FastCGI4D won't work with D2 for various reasons). I have now released
that library, and it currently lives on GitHub.

Without much further ado, let me introduce to you:

D FCGI, a FastCGI library for D.
http://www.github.com/Aatch/dfcgi/

It is basically just a wrapper for the fcgiapp functions in libfcgi
(and as such requires libfcgi to compile). I have tried to make it
simple to use without sacrificing functionality.

I'm fairly new to D, so any feedback on general code quality would be
appreciated.
February 03, 2012
Re: D FCGI
General note: You might want to submit the libfcgi header part to Deimos 
(there is even a project for it already, albeit empty: [1]), and then 
build the convenience functions on top of it. This way, we can avoid 
duplication of efforts if somebody wants to use the C interface directly.

David


[1] https://github.com/D-Programming-Deimos/libfcgi

On 2/3/12 1:31 PM, James Miller wrote:
> Hello everybody,
>
> Before I essentially spam everybody, I'll introduce myself. I am James
> Miller, and English developer living in New Zealand, I started using D
> about 2 months ago and am currently working on a large project using
> it.
>
> As part of that project, I developed a FastCGI library (mostly because
> FastCGI4D won't work with D2 for various reasons). I have now released
> that library, and it currently lives on GitHub.
>
> Without much further ado, let me introduce to you:
>
> D FCGI, a FastCGI library for D.
> http://www.github.com/Aatch/dfcgi/
>
> It is basically just a wrapper for the fcgiapp functions in libfcgi
> (and as such requires libfcgi to compile). I have tried to make it
> simple to use without sacrificing functionality.
>
> I'm fairly new to D, so any feedback on general code quality would be
> appreciated.
February 03, 2012
Re: D FCGI
> D FCGI, a FastCGI library for D.


I've also done something similar:

https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff

check out cgi.d. If you compile with -version=fastcgi, it
uses the libfcgi while keeping the same interface as the
default regular CGI.
February 03, 2012
Re: D FCGI
On Feb 4, 2012 5:38 AM, "Adam D. Ruppe" <destructionator@gmail.com> wrote:
>>
>> D FCGI, a FastCGI library for D.
>
>
>
> I've also done something similar:
>
>
https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff
>
> check out cgi.d. If you compile with -version=fastcgi, it
> uses the libfcgi while keeping the same interface as the
> default regular CGI.

I haven't looked at any of the files yet, but the fact that you have a set
of database modules looks useful. I'll also take a look at how you are
handling things in cgi.d and see if I can improve things in my code from
there.

I wish this kind of stuff was easier to find, putting D <something> in a
search almost never returns anything useful. DSource seems pretty useless
as half the projects haven't been worked on in a while and/or don't work
with D2. I could go on, but don't want to derail my own topic...
February 03, 2012
Re: D FCGI
On Feb 4, 2012 5:31 AM, "David Nadlinger" <see@klickverbot.at> wrote:
>
> General note: You might want to submit the libfcgi header part to Deimos
(there is even a project for it already, albeit empty: [1]), and then build
the convenience functions on top of it. This way, we can avoid duplication
of efforts if somebody wants to use the C interface directly.
>
> David
>
>
> [1] https://github.com/D-Programming-Deimos/libfcgi

Good idea, if I write more headers for it, then I should be able to port
the examples from the fcgi dev kit to D on top of it.
February 04, 2012
Re: D FCGI
On 4/02/2012 1:31 a.m., James Miller wrote:
> Before I essentially spam everybody, I'll introduce myself. I am James
> Miller, and English developer living in New Zealand, I started using D
> about 2 months ago and am currently working on a large project using
> it.

Hi James

where in NZ are you ?

why did you pick D for this large project ?

what industry are you in ?


regards
Nick _B
February 04, 2012
Re: D FCGI
On 4 February 2012 14:07, Nick_B <nick.NOSPAMbarbalich@gmail.com> wrote:
> On 4/02/2012 1:31 a.m., James Miller wrote:
>>
>> Before I essentially spam everybody, I'll introduce myself. I am James
>> Miller, and English developer living in New Zealand, I started using D
>> about 2 months ago and am currently working on a large project using
>> it.
>
>
> Hi James
>
> where in NZ are you ?
>
> why did you pick D for this large project ?
>
> what industry are you in ?
>
>
> regards
> Nick _B

Hey Nick.
I am in Wellington.
I'm using D because I feel it needs more exposure and usage and this
was a good opportunity to do so.
I make a living writing PHP, and until recently have worked freelance.
I now have a permanent position at a start-up as a web developer.

--
James Miller
February 04, 2012
Re: D FCGI
On Friday, 3 February 2012 at 23:15:19 UTC, James Miller wrote:
> I haven't looked at any of the files yet, but the fact that you 
> have a set of database modules looks useful.

Yeah, I used to use php but wanted to ditch it for D, so
everything I needed from php I did in D too, and have since
moved beyond that as well (the other modules give higher level
wrappers, html dom stuff, and more.)

> I'll also take a look at how you are
> handling things in cgi.d and see if I can improve things in my

Two things I noticed your thing didn't do (unless I missed it)
was arrays of parameters and uploaded files.

Arrays of params is easy: in the query string or the POST
data, the names are simply repeated, so you can use a
string[][string] and append to it.

File uploads were a pain to implement, since it uses
MIME encoding, but still not too awful. You can take
whatever you want from my code.


> I wish this kind of stuff was easier to find, putting D 
> <something> in a search almost never returns anything useful.

Aye.
February 04, 2012
Re: D FCGI
>Two things I noticed your thing didn't do (unless I missed it)
>was arrays of parameters and uploaded files.

I parse the GET params, POST params, and FCGI Params and store them in
_getParams, _postParams and _environment respectively. I also
duplicate the GET and POST params into _requestParams (not that memory
efficient, but I can always optimize if it becomes a problem). All of
those are string[string] associative arrays. Is that what you mean? I
don't know what more information I can feasibly grab from the
request...

I didn't think about file uploads. I'd have to implement them
eventually so knowing that you handled it at least gives me something
to start from, thanks.

>Yeah, I used to use php but wanted to ditch it for D,

What a coincidence, me too!
February 04, 2012
Re: D FCGI
On Saturday, 4 February 2012 at 04:37:57 UTC, James Miller wrote:
> I parse the GET params, POST params, and FCGI Params and store 
> them in _getParams, _postParams and _environment

Yeah, that works for the vast majority of cases, but suppose
you go to:

yoursite.com/yourapp?foo=bar&foo=baz

That's allowed and sometimes useful. In PHP, you'd
name a form field "something[]" and access it as an array
of multiple values.

The PHP name thing is just something they do; you can
actually send multiple values for any name, and sometimes
you'll want to be able to access that too.


In my thing, I used a string[string] for get, but also
offered a string[][string] called getArray for the times
when you want to get to multiple values.

(ditto for POST)

> What a coincidence, me too!

D rox.
« First   ‹ Prev
1 2
Top | Discussion index | About this forum | D home