# HG changeset patch # User Christian Hammond # Date 1058238182 0 # Node ID 3de23c9ca1e431747e1636b96949fd45a208dab6 # Parent 2ecab9e88b97867b99fc9c9b947ae0cc0afef997 [gaim-migrate @ 6602] Fixed HTTP redirect handling. If a redirect specified a path without a URL (as is often the case), our redirect handling would crash and burn. Now it only skids along the ground and manages to save itself and retrieve the file. Think Indiana Jones, but with HTTP redirects and giant smileys. committer: Tailor Script diff -r 2ecab9e88b97 -r 3de23c9ca1e4 src/html.c --- a/src/html.c Tue Jul 15 03:00:24 2003 +0000 +++ b/src/html.c Tue Jul 15 03:03:02 2003 +0000 @@ -129,7 +129,8 @@ gchar *s; if ((s = g_strstr_len(data, data_len, "Location: ")) != NULL) { - gchar *new_url, *end; + gchar *new_url, *temp_url, *end; + gboolean full; int len; s += strlen("Location: "); @@ -145,13 +146,28 @@ strncpy(new_url, s, len); new_url[len] = '\0'; + full = gunk->full; + + if (*new_url == '/' || g_strstr_len(new_url, len, "://") == NULL) { + temp_url = new_url; + + new_url = g_strdup_printf("%s:%d%s", gunk->website->address, + gunk->website->port, temp_url); + + g_free(temp_url); + + full = FALSE; + } + /* Close the existing stuff. */ gaim_input_remove(gunk->inpa); close(sock); + gaim_debug(GAIM_DEBUG_INFO, "grab_url", + "Redirecting to %s\n", new_url); + /* Try again, with this new location. */ - grab_url(new_url, gunk->full, gunk->callback, - gunk->data); + grab_url(new_url, full, gunk->callback, gunk->data); /* Free up. */ g_free(new_url);