comparison http.c @ 6263:89adb1f9ff50 libavformat

http: Log a warning when receiving an error code
author mstorsjo
date Fri, 16 Jul 2010 14:15:37 +0000
parents 4fc5e0e4e1cd
children 3472338a5e13
comparison
equal deleted inserted replaced
6262:7b8b71ff9a76 6263:89adb1f9ff50
208 208
209 static int process_line(URLContext *h, char *line, int line_count, 209 static int process_line(URLContext *h, char *line, int line_count,
210 int *new_location) 210 int *new_location)
211 { 211 {
212 HTTPContext *s = h->priv_data; 212 HTTPContext *s = h->priv_data;
213 char *tag, *p; 213 char *tag, *p, *end;
214 214
215 /* end of header */ 215 /* end of header */
216 if (line[0] == '\0') 216 if (line[0] == '\0')
217 return 0; 217 return 0;
218 218
220 if (line_count == 0) { 220 if (line_count == 0) {
221 while (!isspace(*p) && *p != '\0') 221 while (!isspace(*p) && *p != '\0')
222 p++; 222 p++;
223 while (isspace(*p)) 223 while (isspace(*p))
224 p++; 224 p++;
225 s->http_code = strtol(p, NULL, 10); 225 s->http_code = strtol(p, &end, 10);
226 226
227 dprintf(NULL, "http_code=%d\n", s->http_code); 227 dprintf(NULL, "http_code=%d\n", s->http_code);
228 228
229 /* error codes are 4xx and 5xx, but regard 401 as a success, so we 229 /* error codes are 4xx and 5xx, but regard 401 as a success, so we
230 * don't abort until all headers have been parsed. */ 230 * don't abort until all headers have been parsed. */
231 if (s->http_code >= 400 && s->http_code < 600 && s->http_code != 401) 231 if (s->http_code >= 400 && s->http_code < 600 && s->http_code != 401) {
232 end += strspn(end, SPACE_CHARS);
233 av_log(NULL, AV_LOG_WARNING, "HTTP error %d %s\n",
234 s->http_code, end);
232 return -1; 235 return -1;
236 }
233 } else { 237 } else {
234 while (*p != '\0' && *p != ':') 238 while (*p != '\0' && *p != ':')
235 p++; 239 p++;
236 if (*p != ':') 240 if (*p != ':')
237 return 1; 241 return 1;