[FASTCGI] Missing characters from input stream from fastcgi request

Tomas Friml instantni.med at gmail.com
Sun Nov 28 04:17:33 EST 2010


Hi all,

I'm trying to develop simple RESTful api using FastCGI (and restcgi). When I
tried to implement POST method I noticed that the input stream (representing
request body) is wrong. I did a little test and looks like when I try to
read the stream only every other character is received.

Body sent: name=john&surname=smith Received: aejh&unm=mt

I've tried more clients just to make sure it's not the client messing with
the data. My code is:

int main(int argc, char* argv[]) {

  // FastCGI initialization.
  FCGX_Init();
  FCGX_Request request;

  FCGX_InitRequest(&request, 0, 0);

  while (FCGX_Accept_r(&request) >= 0) {

    // FastCGI request setup.
    fcgi_streambuf fisbuf(request.in);

    std::istream is(&fisbuf);
    fcgi_streambuf fosbuf(request.out);

    std::ostream os(&fosbuf);

    std::string str;

    is >> str;
    std::cerr << str;  // this way I can see it in apache error log

    // restcgi code here
  }

  return 0;

}

I'm using fast_cgi module with apache (not sure if that makes any
difference).

Any idea what am I doing wrong?

Cheers, Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.pins.net/mailman/private.cgi/fastcgi-developers/attachments/20101128/2b7971eb/attachment.html>


More information about the FastCGI-developers mailing list