« Previous Next »

Thread: fakefcgi test environment and streams

Last post 11-15-2007 12:22 PM by rickjames. 3 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (4 items)

Sort Posts:

  • 11-14-2007, 2:49 PM

    • pwab
    • Not Ranked
    • Joined on 11-06-2007, 7:38 AM
    • South Africa
    • Posts 6

    fakefcgi test environment and streams

    Hi,

    I tested my fcgi client implementation with the fakefcgi.exe program from Rick Jame's website. At first I made the assumption that the FCGI_PARAMS stream will contain a terminating null-stream (as per the fastcgi spec), but the fakefcgi.exe program does not send that terminator. Even so, the other fastcgi clients (php, perl etc) work correctly without this terminator.

    What is the logic here? Is the fakefcgi program wrong? Or should I assume that once the STDIN records start arriving, no more PARAMS will arrive for that requestId? Or is there some other logic here that I am missing?

    Regards,

    Pieter
     

    --

    Tempus est mensura motus rerum mobilium.
    Time is the measure of movement.

    -- Auctoritates Aristotelis

    +27 82 567 6207
    http://pieterbreed.blogspot.com/
  • 11-14-2007, 4:58 PM In reply to

    Re: fakefcgi test environment and streams

    Hi Pieter,

    I'm definitely not an authority on the protocol spec, but I think this quote makes it pretty clear:

    "When a role protocol uses FCGI_PARAMS to transmit textual values, such as the values that CGI programs obtain from environment variables, the length of the value does not include the terminating null byte, and the value itself does not include a null byte."

    http://www.fastcgi.com/devkit/doc/fcgi-spec.html#S6.1

    Cheerz,

    Rick.

  • 11-14-2007, 9:32 PM In reply to

    • pwab
    • Not Ranked
    • Joined on 11-06-2007, 7:38 AM
    • South Africa
    • Posts 6

    Re: fakefcgi test environment and streams

    Hi Rick,

    Thanks for your reply, and apologies for asking my question so unclearly.

    Actually, I was referring to the stream's terminator and not the null-byte that you find at the end of c-style strings. Please see this section in the spec, in the very last subsection:

    http://www.fastcgi.com/devkit/doc/fcgi-spec.html#S3.3

    The second distinction is between discrete and stream records. A discrete record contains a meaningful unit of data all by itself. A stream record is part of a stream, i.e. a series of zero or more non-empty records (length != 0) of the stream type, followed by an empty record (length == 0) of the stream type.

    lastly, if you look right at the bottom of that page at the examples:

    {FCGI_BEGIN_REQUEST,   1, {FCGI_RESPONDER, FCGI_KEEP_CONN}}
    {FCGI_PARAMS, 1, "\013\002SERVER_PORT80\013\016SERVER_ADDR199.170.183.42 ... "}
    {FCGI_PARAMS, 1, ""}
    {FCGI_BEGIN_REQUEST, 2, {FCGI_RESPONDER, FCGI_KEEP_CONN}}
    {FCGI_PARAMS, 2, "\013\002SERVER_PORT80\013\016SERVER_ADDR199.170.183.42 ... "}
    {FCGI_STDIN, 1, ""}

    {FCGI_STDOUT, 1, "Content-type: text/html\r\n\r\n"}

    {FCGI_PARAMS, 2, ""}
    {FCGI_STDIN, 2, ""}

    {FCGI_STDOUT, 2, "Content-type: text/html\r\n\r\n<html>\n<head> ... "}
    {FCGI_STDOUT, 2, ""}
    {FCGI_END_REQUEST, 2, {0, FCGI_REQUEST_COMPLETE}}
    {FCGI_STDOUT, 1, "<html>\n<head> ... "}
    {FCGI_STDOUT, 1, ""}
    {FCGI_END_REQUEST, 1, {0, FCGI_REQUEST_COMPLETE}}

    So, to get back to the question I wanted to ask: fakefcgi does not actually send such an empty record for the FCGI_PARAMS stream. It seems to me that the clients assume that once FCGI_STDIN starts arriving that no more FCGI_PARAMS records will be sent.

    Regards,

    Pieter 

    --

    Tempus est mensura motus rerum mobilium.
    Time is the measure of movement.

    -- Auctoritates Aristotelis

    +27 82 567 6207
    http://pieterbreed.blogspot.com/
  • 11-15-2007, 12:22 PM In reply to

    Re: fakefcgi test environment and streams

    Hi Pieter,

    You are correct. I've added a second version to the attached zip file here: http://blogs.iis.net/rickjames/archive/2007/02/04/fake-fastcgi-web-server.aspx

    Cheerz,

    Rick.

Page 1 of 1 (4 items)
Microsoft Communities