Issue with HTTPServer

14 Dec 2010

Hi,

I've implemented the HTTPServer library for a project I am doing. But, I have found a serious issue. I don't know if it is caused by something I do or the mechanism inside the HTTPServer class.

This is the request handler class I'm using:

class CSVHandler : public HTTPRequestHandler {
    public:
        CSVHandler (const char * root, const char * path, TCPSocket * sock) 
            : HTTPRequestHandler (root, path, sock)
        { }
        
        virtual ~CSVHandler (void) { }
        virtual void doHead (void) { }
        virtual void doPost (void) { }
        virtual void onReadable (void) { }
        
        virtual void onWriteable (void) { }
        
        virtual void onClose (void) { }
        
        static inline HTTPRequestHandler * inst (const char * root, const char * path, TCPSocket * sock) {
            return new CSVHandler (root, path, sock);
        }
        
        virtual void doGet (void) {
            this->respHeaders ()["Content-Type"]    = "text/plain";
            this->respHeaders ()["Connection"]      = "close";
            
            this->writeData (csv.c_str (), csv.length ());
        }
};

As you can see, I use a std::string to store a CSV data string in. But...when the length of this string is MORE than 980 bytes (or characters if you prefer). I have no idea what the problem could be. Should I specify the HTTP charset? Or is it something else?

Kind regards, Ramon Kleiss

14 Dec 2010

"when the length of this string is MORE than 980 bytes" then what?

14 Dec 2010

Oh, yeah, I forgot to finish the sentence :'). When the length of the string is more than 980 bytes, the string is not received by the browser...

14 Dec 2010

I wonder if it has something to do with the MTU size.

14 Dec 2010

The MTU has a size of 1500 (kinda the default, right?) But you could be right, in that case, should I send it in parts of about 600 bytes or something like that? And if so, how do I do that? :P