diff s3/s3_uploader.c @ 206:240337164a80

[Seobeo] SSL should be used for large file as well lol.
author MrJuneJune <me@mrjunejune.com>
date Sun, 15 Feb 2026 11:41:53 -0800
parents 6cdee35a7ba9
children
line wrap: on
line diff
--- a/s3/s3_uploader.c	Sun Feb 15 11:07:52 2026 -0800
+++ b/s3/s3_uploader.c	Sun Feb 15 11:41:53 2026 -0800
@@ -153,24 +153,20 @@
   }
 
   // Build canonical headers (must be sorted alphabetically)
-  char content_length_str[32];
-  snprintf(content_length_str, sizeof(content_length_str), "%zu", data_length);
-
-  size_t headers_len = 512 + strlen(host) + strlen(content_type) + strlen(content_length_str);
+  // Note: Content-Length is NOT signed for S3 PUT requests (it's sent but not in signature)
+  size_t headers_len = 512 + strlen(host) + strlen(content_type);
   char *canonical_headers = Dowa_Arena_Allocate(p_arena, headers_len);
   snprintf(canonical_headers, headers_len,
-           "content-length:%s\n"
            "content-type:%s\n"
            "host:%s\n"
            "x-amz-content-sha256:%s\n"
            "x-amz-date:%s\n",
-           content_length_str,
            content_type,
            host,
            payload_hash,
            ts.datetime);
 
-  const char *signed_headers = "content-length;content-type;host;x-amz-content-sha256;x-amz-date";
+  const char *signed_headers = "content-type;host;x-amz-content-sha256;x-amz-date";
 
   // Build canonical request
   char *canonical_request = s3__build_canonical_request("PUT",
@@ -213,11 +209,18 @@
   Seobeo_Client_Request *p_req = Seobeo_Client_Request_Create(url);
   Seobeo_Client_Request_Set_Method(p_req, "PUT");
   Seobeo_Client_Request_Set_Body(p_req, (const char *)data, data_length);
+  Seobeo_Client_Request_Add_Header_Map(p_req, "Connection", "keep-alive");
   Seobeo_Client_Request_Add_Header_Map(p_req, "Content-Type", content_type);
   Seobeo_Client_Request_Add_Header_Map(p_req, "x-amz-date", ts.datetime);
   Seobeo_Client_Request_Add_Header_Map(p_req, "x-amz-content-sha256", payload_hash);
   Seobeo_Client_Request_Add_Header_Map(p_req, "Authorization", auth_header);
 
+  Seobeo_Log(SEOBEO_DEBUG, "[S3] Uploading %zu bytes to %s\n", data_length, url);
+  Seobeo_Log(SEOBEO_DEBUG, "[S3] Content-Type: %s\n", content_type);
+  Seobeo_Log(SEOBEO_DEBUG, "[S3] x-amz-date: %s\n", ts.datetime);
+  Seobeo_Log(SEOBEO_DEBUG, "[S3] x-amz-content-sha256: %s\n", payload_hash);
+  Seobeo_Log(SEOBEO_DEBUG, "[S3] Authorization: %.80s...\n", auth_header);
+
   Seobeo_Client_Response *p_resp = Seobeo_Client_Request_Execute(p_req);
 
   if (p_resp)