So you're making a proxy.
I suggest not using static variables in a request handler.
They can be overridden by any other random request.
use conn->connection_param instead.
Pass it to the client as a parameter.




On Tue, Feb 4, 2014 at 8:34 AM, nietsnie <[email protected]> wrote:

> Hi all,
>
> I start a server with a URI handler called cmgmRequestHandler. First time
> cmgmRequestHandler will return MG_REQUEST_CALL_AGAIN and send a request to
> another web server via mg_connect call. After download success from another
> server the Request Handler will call mg_send_data to give browser a
> response which content comes from another server.
>
> I find that after download success and call mg_send_data the request
> handler return MG_REQUEST_PROCESSED, the browser can not catch the response.
> Anyone can give me a right solution? Thanks very much!
>
> static int cmgmRequestHandler(struct mg_connection *conn)
> {
>     static ConnectionParam param;
>
>     if (isIdle(&param))
>     {
>         if (isConnect(conn))
>         {
>             printf("Connect Control Module!\n");
>             mg_connect(server, "127.0.0.1", 8090,  0, ts1, &param);
>             param.status = MG_PARAM_CONNECTING;
>             return MG_REQUEST_CALL_AGAIN;
>         }
>         else
>         {
>             printf("Other Request!\n");
>             return MG_REQUEST_NOT_PROCESSED;
>         }
>     }
>     if (isConnecting(&param) || isConnected(&param))
>     {
>         printf("Connecting Control Module!\n");
>         return MG_REQUEST_CALL_AGAIN;
>     }
>     else if (isDownloadSuccess(&param))
>     {
>         printf("Control Module Download Success!\n");
>         mg_send_data(conn, param.content, strlen(param.content));
>         param.status = MG_PARAM_ERROR;
>         return MG_REQUEST_PROCESSED;
>     }
>
>     return MG_REQUEST_NOT_PROCESSED;
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "mongoose-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/mongoose-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to