Mercurial > pidgin.yaz
comparison src/html.c @ 6128:3de23c9ca1e4
[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 <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 15 Jul 2003 03:03:02 +0000 |
parents | 11bedb793a44 |
children | 64d952098596 |
comparison
equal
deleted
inserted
replaced
6127:2ecab9e88b97 | 6128:3de23c9ca1e4 |
---|---|
127 struct grab_url_data *gunk) | 127 struct grab_url_data *gunk) |
128 { | 128 { |
129 gchar *s; | 129 gchar *s; |
130 | 130 |
131 if ((s = g_strstr_len(data, data_len, "Location: ")) != NULL) { | 131 if ((s = g_strstr_len(data, data_len, "Location: ")) != NULL) { |
132 gchar *new_url, *end; | 132 gchar *new_url, *temp_url, *end; |
133 gboolean full; | |
133 int len; | 134 int len; |
134 | 135 |
135 s += strlen("Location: "); | 136 s += strlen("Location: "); |
136 end = strchr(s, '\r'); | 137 end = strchr(s, '\r'); |
137 | 138 |
143 | 144 |
144 new_url = g_malloc(len + 1); | 145 new_url = g_malloc(len + 1); |
145 strncpy(new_url, s, len); | 146 strncpy(new_url, s, len); |
146 new_url[len] = '\0'; | 147 new_url[len] = '\0'; |
147 | 148 |
149 full = gunk->full; | |
150 | |
151 if (*new_url == '/' || g_strstr_len(new_url, len, "://") == NULL) { | |
152 temp_url = new_url; | |
153 | |
154 new_url = g_strdup_printf("%s:%d%s", gunk->website->address, | |
155 gunk->website->port, temp_url); | |
156 | |
157 g_free(temp_url); | |
158 | |
159 full = FALSE; | |
160 } | |
161 | |
148 /* Close the existing stuff. */ | 162 /* Close the existing stuff. */ |
149 gaim_input_remove(gunk->inpa); | 163 gaim_input_remove(gunk->inpa); |
150 close(sock); | 164 close(sock); |
151 | 165 |
166 gaim_debug(GAIM_DEBUG_INFO, "grab_url", | |
167 "Redirecting to %s\n", new_url); | |
168 | |
152 /* Try again, with this new location. */ | 169 /* Try again, with this new location. */ |
153 grab_url(new_url, gunk->full, gunk->callback, | 170 grab_url(new_url, full, gunk->callback, gunk->data); |
154 gunk->data); | |
155 | 171 |
156 /* Free up. */ | 172 /* Free up. */ |
157 g_free(new_url); | 173 g_free(new_url); |
158 g_free(gunk->webdata); | 174 g_free(gunk->webdata); |
159 g_free(gunk->website); | 175 g_free(gunk->website); |