Mercurial > ecos
comparison packages/redboot/current/src/net/http_client.c @ 898:6f9085944169
Improve download error handling. Also display more info during load.
| author | gthomas |
|---|---|
| date | Thu, 03 Apr 2003 15:21:10 +0000 |
| parents | 78a5b319acd3 |
| children | fc4fa5d81cba |
comparison
equal
deleted
inserted
replaced
| 897:07ad44cfd9a4 | 898:6f9085944169 |
|---|---|
| 7 //========================================================================== | 7 //========================================================================== |
| 8 //####ECOSGPLCOPYRIGHTBEGIN#### | 8 //####ECOSGPLCOPYRIGHTBEGIN#### |
| 9 // ------------------------------------------- | 9 // ------------------------------------------- |
| 10 // This file is part of eCos, the Embedded Configurable Operating System. | 10 // This file is part of eCos, the Embedded Configurable Operating System. |
| 11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. | 11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
| 12 // Copyright (C) 2002 Gary Thomas | 12 // Copyright (C) 2002, 2003 Gary Thomas |
| 13 // | 13 // |
| 14 // eCos is free software; you can redistribute it and/or modify it under | 14 // eCos is free software; you can redistribute it and/or modify it under |
| 15 // the terms of the GNU General Public License as published by the Free | 15 // the terms of the GNU General Public License as published by the Free |
| 16 // Software Foundation; either version 2 or (at your option) any later version. | 16 // Software Foundation; either version 2 or (at your option) any later version. |
| 17 // | 17 // |
| 171 while ((s->avail > 0) && (*s->bufp == ' ')) { | 171 while ((s->avail > 0) && (*s->bufp == ' ')) { |
| 172 s->bufp++; | 172 s->bufp++; |
| 173 s->avail--; | 173 s->avail--; |
| 174 } | 174 } |
| 175 if (strncmp(s->bufp, "OK", 2)) { | 175 if (strncmp(s->bufp, "OK", 2)) { |
| 176 *err = HTTP_BADHDR; | 176 switch (code) { |
| 177 case 400: | |
| 178 *err = HTTP_BADREQ; | |
| 179 break; | |
| 180 case 404: | |
| 181 *err = HTTP_NOFILE; | |
| 182 break; | |
| 183 default: | |
| 184 *err = HTTP_BADHDR; | |
| 185 break; | |
| 186 } | |
| 177 return -1; | 187 return -1; |
| 178 } | 188 } |
| 179 // Find \r\n\r\n - end of HTTP preamble | 189 // Find \r\n\r\n - end of HTTP preamble |
| 180 while (s->avail > 4) { | 190 while (s->avail > 4) { |
| 181 // This could be done faster, but not simpler | 191 // This could be done faster, but not simpler |
| 222 switch (err) { | 232 switch (err) { |
| 223 case HTTP_NOERR: | 233 case HTTP_NOERR: |
| 224 return ""; | 234 return ""; |
| 225 case HTTP_BADHDR: | 235 case HTTP_BADHDR: |
| 226 return "Unrecognized HTTP response"; | 236 return "Unrecognized HTTP response"; |
| 237 case HTTP_BADREQ: | |
| 238 return "Bad HTTP request (check file name)"; | |
| 239 case HTTP_NOFILE: | |
| 240 return "No such file"; | |
| 227 case HTTP_OPEN: | 241 case HTTP_OPEN: |
| 228 return "Can't connect to host"; | 242 return "Can't connect to host"; |
| 229 case HTTP_IO: | 243 case HTTP_IO: |
| 230 return "I/O error"; | 244 return "I/O error"; |
| 231 } | 245 } |
