Explorar o código

check response

jblanked hai 1 ano
pai
achega
e09fd2d233
Modificáronse 2 ficheiros con 17 adicións e 12 borrados
  1. 9 4
      callback/web_crawler_callback.c
  2. 8 8
      flipper_http/flipper_http.c

+ 9 - 4
callback/web_crawler_callback.c

@@ -742,14 +742,15 @@ static char *web_crawler_parse(DataLoaderModel *model)
             FuriString *returned_data = flipper_http_load_from_file(model->fhttp->file_path);
             if (returned_data == NULL || furi_string_size(returned_data) == 0)
             {
-                return "Failed to load HTML response.\nPress BACK to return.";
+                return "Failed to load HTML response.\n\n\n\n\nPress BACK to return.";
             }
 
             // head is mandatory,
             bool head_exists = html_furi_tag_exists("<head>", returned_data, 0);
             if (!head_exists)
             {
-                return "Invalid HTML response.\nPress BACK to return.";
+                FURI_LOG_E(TAG, "Invalid HTML response");
+                return "Invalid HTML response.\n\n\n\n\nPress BACK to return.";
             }
 
             // optional tags but we'll append them the response in order (title -> h1 -> h2 -> h3 -> p)
@@ -796,10 +797,14 @@ static char *web_crawler_parse(DataLoaderModel *model)
                 furi_string_free(p);
             }
             furi_string_free(returned_data);
-            return (char *)furi_string_get_cstr(response);
+            if (response && furi_string_size(response) > 0)
+            {
+                return (char *)furi_string_get_cstr(response);
+            }
+            return "No HTML tags found.\nTry another URL...\n\n\n\nPress BACK to return.";
         }
     }
-    return "Data saved to file.\nPress BACK to return.";
+    return "Data saved to file.\n\n\n\n\nPress BACK to return.";
 }
 
 static void web_crawler_data_switch_to_view(WebCrawlerApp *app)

+ 8 - 8
flipper_http/flipper_http.c

@@ -602,14 +602,14 @@ bool flipper_http_send_data(FlipperHTTP *fhttp, const char *data)
 
     // Create a buffer with data + '\n'
     size_t send_length = data_length + 1; // +1 for '\n'
-    if (send_length > 256)
+    if (send_length > 512)
     { // Ensure buffer size is sufficient
         FURI_LOG_E("FlipperHTTP", "Data too long to send over FHTTP->");
         return false;
     }
 
-    char send_buffer[257]; // 256 + 1 for safety
-    strncpy(send_buffer, data, 256);
+    char send_buffer[513]; // 512 + 1 for safety
+    strncpy(send_buffer, data, 512);
     send_buffer[data_length] = '\n';     // Append newline
     send_buffer[data_length + 1] = '\0'; // Null-terminate
 
@@ -1006,7 +1006,7 @@ bool flipper_http_get_request(FlipperHTTP *fhttp, const char *url)
     }
 
     // Prepare GET request command
-    char command[256];
+    char command[512];
     int ret = snprintf(command, sizeof(command), "[GET]%s", url);
     if (ret < 0 || ret >= (int)sizeof(command))
     {
@@ -1049,7 +1049,7 @@ bool flipper_http_get_request_with_headers(FlipperHTTP *fhttp, const char *url,
     }
 
     // Prepare GET request command with headers
-    char command[256];
+    char command[512];
     int ret = snprintf(
         command, sizeof(command), "[GET/HTTP]{\"url\":\"%s\",\"headers\":%s}", url, headers);
     if (ret < 0 || ret >= (int)sizeof(command))
@@ -1092,7 +1092,7 @@ bool flipper_http_get_request_bytes(FlipperHTTP *fhttp, const char *url, const c
     }
 
     // Prepare GET request command with headers
-    char command[256];
+    char command[512];
     int ret = snprintf(
         command, sizeof(command), "[GET/BYTES]{\"url\":\"%s\",\"headers\":%s}", url, headers);
     if (ret < 0 || ret >= (int)sizeof(command))
@@ -1142,7 +1142,7 @@ bool flipper_http_post_request_with_headers(
     }
 
     // Prepare POST request command with headers and data
-    char command[256];
+    char command[512];
     int ret = snprintf(
         command,
         sizeof(command),
@@ -1192,7 +1192,7 @@ bool flipper_http_post_request_bytes(FlipperHTTP *fhttp, const char *url, const
     }
 
     // Prepare POST request command with headers and data
-    char command[256];
+    char command[512];
     int ret = snprintf(
         command,
         sizeof(command),