httpd: fix warnings, more robust error handling, improved MIME handling
authorØyvind Harboe <oyvind.harboe@zylin.com>
Sun, 8 Nov 2009 18:50:35 +0000 (19:50 +0100)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Tue, 10 Nov 2009 07:50:06 +0000 (08:50 +0100)
The httpd is work in progress...

No mime type set by default. Let the browser guess.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
src/server/httpd.c

index 0ddeb97acc67b9cd7cd9718196be5c633bc0439e..d8659b09e6c39c7d64a4da8abaf041fef5dbd7bf 100644 (file)
@@ -123,7 +123,7 @@ static int httpd_Jim_Command_writeform(Jim_Interp *interp, int argc,
 
        const char *script = alloc_printf("set dummy_val $httppostdata(%s); set dummy_val",
                        name);
-       retcode = Jim_Eval_Named(interp, script, "httpd.c", __LINE__);
+       retcode = Jim_Eval_Named(interp, script, __FILE__, __LINE__);
        free((void *) script);
        if (retcode != JIM_OK)
                return retcode;
@@ -164,7 +164,7 @@ httpd_Jim_Command_formfetch(Jim_Interp *interp,
 
     const char *script = alloc_printf("set dummy_val $httppostdata(%s); set dummy_val",
                        name);
-       int retcode = Jim_Eval_Named(interp, script, "httpd.c", __LINE__);
+       int retcode = Jim_Eval_Named(interp, script, __FILE__, __LINE__);
        free((void *) script);
        if (retcode != JIM_OK)
        {
@@ -288,10 +288,10 @@ static int handle_request(struct MHD_Connection * connection, const char * url)
 
                const char *script = alloc_printf(
                                "global httpdata; source {%s}; set httpdata", url);
-               retcode = Jim_Eval_Named(interp, script, "httpd.c", __LINE__);
+               retcode = Jim_Eval_Named(interp, script, __FILE__, __LINE__);
                free((void *) script);
 
-               if (retcode == JIM_ERR)
+               if (retcode != JIM_OK)
                {
                        printf("Tcl failed\n");
                        const char *t = httpd_exec_cgi_tcl_error(interp);
@@ -341,7 +341,10 @@ static int handle_request(struct MHD_Connection * connection, const char * url)
                LOG_DEBUG("Serving %s length=%zu", url, len);
                /* serve file directly */
                response = MHD_create_response_from_data(len, data, MHD_YES, MHD_NO);
+               /* Should we expose mimetype via tcl here or just let the browser
+                  guess?
                MHD_add_response_header(response, "Content-Type", "image/png");
+               */
 
                ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
                MHD_destroy_response(response);
@@ -353,7 +356,7 @@ static int handle_request(struct MHD_Connection * connection, const char * url)
 
 static int ahc_echo_inner(void * cls, struct MHD_Connection * connection,
                const char * url, const char * method, const char * version,
-               const char * upload_data, unsigned int * upload_data_size, void ** ptr)
+               const char * upload_data, size_t * upload_data_size, void ** ptr)
 {
        int post = 0;
 
@@ -442,7 +445,7 @@ static int ahc_echo_inner(void * cls, struct MHD_Connection * connection,
 
 static int ahc_echo(void * cls, struct MHD_Connection * connection,
                const char * url, const char * method, const char * version,
-               const char * upload_data, unsigned int * upload_data_size, void ** ptr)
+               const char * upload_data, size_t * upload_data_size, void ** ptr)
 {
        int result;
 

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)