summaryrefslogtreecommitdiff
blob: 817add8c7bede49df3fb3a6bc45367ff24dbf710 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
--- daapsharing/rb-daap-src.c	2007/01/07 12:16:12	4725
+++ daapsharing/rb-daap-src.c	2007/01/27 02:34:51	4760
@@ -601,6 +601,7 @@
 	gchar *request;
 	gchar *response;
 	gchar *end_headers;
+	gchar first_byte;
 	size_t readsize;
 	gboolean ok = TRUE;
 	guint http_status;
@@ -704,10 +705,13 @@
 	}
 
 	/* libsoup wants the headers null-terminated, despite taking a parameter
-	 * specifying how long they are.
+	 * specifying how long they are.  since the byte we overwrite to null-
+	 * terminate the headers is the first byte of the response body, we need
+	 * to restore it once we've parsed the response headers.
 	 */
-	end_headers[2] = '\0';
-	end_headers += 4;
+	first_byte = end_headers[4];
+	end_headers[4] = '\0';
+	end_headers += 2;
 
 	header_table = g_hash_table_new (soup_str_case_hash, soup_str_case_equal);
 	if (soup_headers_parse_response (response,
@@ -758,6 +762,10 @@
 	g_free (http_status_phrase);
 	g_hash_table_destroy (header_table);
 
+	/* restore the first response body byte and move on */
+	end_headers += 2;
+	*end_headers = first_byte;
+
 	/* copy remaining data into a new buffer */
 	if (ok) {
 		src->buffer_size = readsize - (end_headers - response);