thamagates / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

post_data seems to be NULL or contain less value #121

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I have post some data by using Flex to the Mongoose webserver. It works
fine in normal cases. But, while sending large data through post request
mg_request_info post_data seems to be partially retrieved.

http://localhost:8080/?MachineName=testsystem&xmlBackupData=<XMLWithMMorethan500
0Characters>&Action=Testing

Here, the xmlBackupData contains more than 5000 characters. If I copy the
exact url in firefox then I get the expected result. But, while send this
request via Flex to Mongoose webserver (as a POST request)... I could not
get the entire xml. Seems, I get only partial xml. Sometimes the post_data
seems to be NULL and post_data_length seems to be empty. 

Is there any size limit for post_data_length ? or how to correct my issue.

What version of the product are you using? On what operating system?

Windows XP (Mongoose 2.8)

Please provide any additional information below.

I have created a static library of Mongoose and link in a C++ application. 

I have copied, some of my code here..

Please check this and update me is there any issues

___________________________________________

void Process(struct mg_connection *conn, const struct mg_request_info *ri,
void *data)
{
    mg_printf(conn, "HTTP/1.1 200 OK\r\n"
        "content-Type: text/html\r\n\r\n");

    char* _action = mg_get_var(conn, "Action");
    if (_action != NULL)
    {
        string action = _action;
        mg_free(_action);
    }
    else
    {
        cout<<"Empty::\n";
    }

    char* xmlData = mg_get_var(conn, "xmlBackupData");
    if (xmlData != NULL)
    {
        string xmlDataStr = xmlData;
        mg_free(xmlData);
    }
    else
    {
        cout<<"Empty::\n";
    }
}

___________________________________________

Thanks in Advance,

Original issue reported on code.google.com by asharud...@gmail.com on 19 Feb 2010 at 11:35

Attachments:

GoogleCodeExporter commented 9 years ago
Some of the code I missed to post in previous thread:

void WebServer::ThreadProcess()
{
    struct mg_context *ctx;
    try
    {
        ctx = mg_start();

        mg_set_option(ctx, "ports", "8080");            

        mg_set_auth_callback(ctx, "/*", &WebServer::Process, NULL);

        for (;;)
        {
            Sleep(1000);
        }
    }
    catch(const char* err)
    {

        delete[] (char*) err;       
    }
    catch(...)
    {
        cout << "######## Some Other Error in WebServer..\n";
    }
    mg_stop(ctx);
}

Original comment by asharud...@gmail.com on 19 Feb 2010 at 12:06

GoogleCodeExporter commented 9 years ago
Hi,

It seems the MAX_REQUEST_SIZE cause this issue. By default it is set to 8192. I 
have
changed it to 65536 and seems work now.

However, I will confirm it once again and update this thread tomorrow.

thanks.

Original comment by asharud...@gmail.com on 19 Feb 2010 at 3:41

GoogleCodeExporter commented 9 years ago
Hi,

I tried several times.

After changing the buffer size it seems to be work. However, sometime I face 
the same
issue occasionally. 

Anybody face this issue? or any fix for this issue.

Thanks in Advance.

Original comment by asharud...@gmail.com on 22 Feb 2010 at 10:19

GoogleCodeExporter commented 9 years ago
Hi,

After analyzing the code, I found the issue.. Only with multiple read we can 
get the
actual data from the socket.. I have modified the code and attached my 
mongoose.c
file with this comment.

By using this fix, I can read large data and receive data without any issue.

You can refer the fix from the attached file:

Modified functions are, 
1. mg_printf (Dynamically allocate size based on the data.)
2. read_request (Modified for multiple socket read)
3. process_new_connection (Modified for multiple socket read)

Thanks,

Original comment by asharud...@gmail.com on 8 Mar 2010 at 1:42

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks, I'll take a look.

Original comment by valenok on 8 Mar 2010 at 9:51

GoogleCodeExporter commented 9 years ago
Obsoleted by 2.9.
POST data must be read by user.

Original comment by valenok on 7 Sep 2010 at 8:47