4 Replies Latest reply on Aug 27, 2018 12:31 PM by pasic_3515226

    WICED Studio - Server application using wildcard character (*) in web page data base

      Creating a server application with all dynamic pages.Using the WICED macro START_OF_HTTP_PAGE_DATABASE to define all the possible web pages and page callbacks. In our app can treat the pages generically so only a single callback needed for all our pages - relying on the fact that WICED will provide the specific filename and/or data to the callback function.

       

      Since we will have many pages (more than shown below) I would prefer to use wildcard syntax in the web page data base, see below. There appears to be a WICED problem related to this.

       

      If a POST request, we parse the data (part of the parameter http_data in the callback) for some keywords specific to our application. Then we read the file passed as parameter url_path from our embedded file system and serve that via the WICED api  wiced_http_response_stream_write. The problem is sometimes a POST request is divided over 2 packets. In the first packet the file name is correct, but no data is attached, http_data->message_data_length = 0. The subsequent packet will have the data but now the filename is incorrect, it is as specified in the web page data base, "*.html". If I do not use wildcard characters in the data base and populate it explicitly with all the possible files everything works as expected. Moving forward we may have hundreds of possible pages so the use of wildcard in the web page data base is needed.

       

      // signature of our page callback.....

      static int32_t pageCallback(const char* url_path, const char* url_parameters, wiced_http_response_stream_t* stream, void* arg, wiced_http_message_body_t * http_data )

       

      // example of a portion of web page data based when all files explicitly defined

      START_OF_HTTP_PAGE_DATABASE(ap_web_pages)

          ROOT_HTTP_PAGE_REDIRECT("/indexhme.htm"),

       

          { "/upload_a.htm", "text/html", WICED_DYNAMIC_URL_CONTENT, .url_content.dynamic_data   = { pageCallback,PostUpload}, },

          { "/buftmp.htm", "text/html", WICED_DYNAMIC_URL_CONTENT, .url_content.dynamic_data   = { pageCallback,PostUpload}, },

          { "/buftmp1.htm", "text/html", WICED_DYNAMIC_URL_CONTENT, .url_content.dynamic_data   = { pageCallback,PostUpload}, },

          { "/buftmp2.htm", "text/html", WICED_DYNAMIC_URL_CONTENT, .url_content.dynamic_data   = { pageCallback,PostUpdate}, },

          { "/buftmp3.htm", "text/html", WICED_DYNAMIC_URL_CONTENT, .url_content.dynamic_data   = { pageCallback,PostUpload}, },

          { "/filepost.htm", "text/html", WICED_DYNAMIC_URL_CONTENT, .url_content.dynamic_data   = { pageCallback,PostUpload}, },

       

       

      // example of a portion of our web page database using wildcard

      START_OF_HTTP_PAGE_DATABASE(ap_web_pages)

          ROOT_HTTP_PAGE_REDIRECT("/indexhme.htm"), // real home

       

          { "/*.htm", "text/html", WICED_DYNAMIC_URL_CONTENT, .url_content.dynamic_data   = { pageCallback,PostUpload}, }, // DAT file