added optional button to restart game (door, panel and touch variants)
[rocksndiamonds.git] / src / libgame / http.c
index 0064bc14e5e3bdf01001dedfeba1ca1ea16c0c32..c83c91f71b1515695da8540a0f7c384b9c4f74ea 100644 (file)
@@ -65,18 +65,18 @@ static void SetHttpResponseToDefaults(struct HttpResponse *response)
   response->status_text[0] = '\0';
 }
 
-struct HttpResponse *GetHttpResponseFromBuffer(void *buffer, int size)
+struct HttpResponse *GetHttpResponseFromBuffer(void *buffer, int body_size)
 {
-  if (size > MAX_HTTP_BODY_SIZE)
+  if (body_size > MAX_HTTP_BODY_SIZE)
     return NULL;
 
   struct HttpResponse *response = checked_calloc(sizeof(struct HttpResponse));
 
   SetHttpResponseToDefaults(response);
 
-  strncpy(response->body, buffer, MAX_HTTP_BODY_SIZE);
-  response->body[MAX_HTTP_BODY_SIZE] = '\0';
-  response->body_size = MIN(size, MAX_HTTP_BODY_SIZE);
+  memcpy(response->body, buffer, body_size);
+  response->body[body_size] = '\0';
+  response->body_size = body_size;
 
   return response;
 }
@@ -393,9 +393,9 @@ static boolean DoHttpRequestExt(struct HttpRequest *request,
 boolean DoHttpRequest(struct HttpRequest *request,
                      struct HttpResponse *response)
 {
-  int max_http_buffer_size = MAX_HTTP_HEAD_SIZE + MAX_HTTP_BODY_SIZE;
-  char *send_buffer = checked_malloc(max_http_buffer_size + 1);
-  char *recv_buffer = checked_malloc(max_http_buffer_size + 1);
+  int max_http_buffer_size = MAX_HTTP_HEAD_SIZE + 2 + MAX_HTTP_BODY_SIZE + 1;
+  char *send_buffer = checked_malloc(max_http_buffer_size);
+  char *recv_buffer = checked_malloc(max_http_buffer_size);
   SDLNet_SocketSet socket_set = NULL;
   TCPsocket socket = NULL;