adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2002, Adam Dunkels. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above |
| 11 | * copyright notice, this list of conditions and the following |
| 12 | * disclaimer in the documentation and/or other materials provided |
| 13 | * with the distribution. |
adamdunkels | 06f897e | 2004-06-06 05:59:20 +0000 | [diff] [blame] | 14 | * 3. The name of the author may not be used to endorse or promote |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 15 | * products derived from this software without specific prior |
| 16 | * written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
| 19 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| 24 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | * |
| 30 | * This file is part of the "contiki" web browser. |
| 31 | * |
adamdunkels | 46cd143 | 2004-07-04 17:50:39 +0000 | [diff] [blame] | 32 | * $Id: webclient.c,v 1.18 2004/07/04 17:50:39 adamdunkels Exp $ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 33 | * |
| 34 | */ |
| 35 | |
adamdunkels | 46cd143 | 2004-07-04 17:50:39 +0000 | [diff] [blame] | 36 | #include "ek.h" |
| 37 | #include "tcpip.h" |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 38 | #include "uip.h" |
| 39 | #include "webclient.h" |
| 40 | #include "resolv.h" |
adamdunkels | db300d2 | 2004-02-24 09:57:49 +0000 | [diff] [blame] | 41 | #include "uiplib.h" |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 42 | |
adamdunkels | 873b6c7 | 2003-08-09 13:31:54 +0000 | [diff] [blame] | 43 | #include "www-conf.h" |
| 44 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 45 | #include <string.h> |
| 46 | |
| 47 | #define WEBCLIENT_TIMEOUT 100 |
| 48 | |
| 49 | #define WEBCLIENT_STATE_STATUSLINE 0 |
| 50 | #define WEBCLIENT_STATE_HEADERS 1 |
| 51 | #define WEBCLIENT_STATE_DATA 2 |
| 52 | #define WEBCLIENT_STATE_CLOSE 3 |
| 53 | |
| 54 | #define HTTPFLAG_NONE 0 |
| 55 | #define HTTPFLAG_OK 1 |
| 56 | #define HTTPFLAG_MOVED 2 |
| 57 | #define HTTPFLAG_ERROR 3 |
| 58 | |
| 59 | |
| 60 | #define ISO_nl 0x0a |
| 61 | #define ISO_cr 0x0d |
| 62 | #define ISO_space 0x20 |
| 63 | |
| 64 | struct webclient_state { |
| 65 | u8_t timer; |
| 66 | u8_t state; |
| 67 | u8_t httpflag; |
| 68 | |
| 69 | u16_t port; |
| 70 | char host[40]; |
adamdunkels | 873b6c7 | 2003-08-09 13:31:54 +0000 | [diff] [blame] | 71 | char file[WWW_CONF_MAX_URLLEN]; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 72 | u16_t getrequestptr; |
| 73 | u16_t getrequestleft; |
| 74 | |
adamdunkels | c583d21 | 2003-08-24 22:36:31 +0000 | [diff] [blame] | 75 | char httpheaderline[200]; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 76 | u16_t httpheaderlineptr; |
| 77 | |
| 78 | char mimetype[32]; |
| 79 | }; |
| 80 | |
| 81 | static struct webclient_state s; |
| 82 | |
| 83 | /*-----------------------------------------------------------------------------------*/ |
| 84 | char * |
| 85 | webclient_mimetype(void) |
| 86 | { |
adamdunkels | af90817 | 2003-03-28 12:07:54 +0000 | [diff] [blame] | 87 | return s.mimetype; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 88 | } |
| 89 | /*-----------------------------------------------------------------------------------*/ |
| 90 | char * |
| 91 | webclient_filename(void) |
| 92 | { |
adamdunkels | af90817 | 2003-03-28 12:07:54 +0000 | [diff] [blame] | 93 | return s.file; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 94 | } |
| 95 | /*-----------------------------------------------------------------------------------*/ |
| 96 | char * |
| 97 | webclient_hostname(void) |
| 98 | { |
adamdunkels | af90817 | 2003-03-28 12:07:54 +0000 | [diff] [blame] | 99 | return s.host; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 100 | } |
| 101 | /*-----------------------------------------------------------------------------------*/ |
| 102 | unsigned short |
| 103 | webclient_port(void) |
| 104 | { |
| 105 | return s.port; |
| 106 | } |
| 107 | /*-----------------------------------------------------------------------------------*/ |
| 108 | void |
| 109 | webclient_init(void) |
| 110 | { |
| 111 | |
| 112 | } |
| 113 | /*-----------------------------------------------------------------------------------*/ |
| 114 | static void |
| 115 | init_connection(void) |
| 116 | { |
| 117 | s.state = WEBCLIENT_STATE_STATUSLINE; |
| 118 | |
| 119 | s.getrequestleft = sizeof(http_get) - 1 + 1 + |
| 120 | sizeof(http_10) - 1 + |
| 121 | sizeof(http_crnl) - 1 + |
| 122 | sizeof(http_host) - 1 + |
| 123 | sizeof(http_crnl) - 1 + |
adamdunkels | 09c3c76 | 2003-07-31 23:32:04 +0000 | [diff] [blame] | 124 | strlen(http_user_agent_fields) + |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 125 | strlen(s.file) + strlen(s.host); |
| 126 | s.getrequestptr = 0; |
| 127 | |
| 128 | s.httpheaderlineptr = 0; |
| 129 | } |
| 130 | /*-----------------------------------------------------------------------------------*/ |
| 131 | void |
| 132 | webclient_close(void) |
| 133 | { |
| 134 | s.state = WEBCLIENT_STATE_CLOSE; |
| 135 | } |
| 136 | /*-----------------------------------------------------------------------------------*/ |
| 137 | unsigned char |
| 138 | webclient_get(char *host, u16_t port, char *file) |
| 139 | { |
| 140 | struct uip_conn *conn; |
| 141 | u16_t *ipaddr; |
adamdunkels | e6a3f18 | 2003-08-22 19:22:58 +0000 | [diff] [blame] | 142 | static u16_t addr[2]; |
adamdunkels | e3fa8fa | 2003-06-30 21:26:42 +0000 | [diff] [blame] | 143 | |
| 144 | /* First check if the host is an IP address. */ |
| 145 | ipaddr = &addr[0]; |
adamdunkels | db300d2 | 2004-02-24 09:57:49 +0000 | [diff] [blame] | 146 | if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) { |
adamdunkels | e3fa8fa | 2003-06-30 21:26:42 +0000 | [diff] [blame] | 147 | ipaddr = resolv_lookup(host); |
| 148 | |
| 149 | if(ipaddr == NULL) { |
| 150 | return 0; |
| 151 | } |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 152 | } |
| 153 | |
adamdunkels | 46cd143 | 2004-07-04 17:50:39 +0000 | [diff] [blame] | 154 | conn = tcp_connect(ipaddr, htons(port), NULL); |
adamdunkels | e3fa8fa | 2003-06-30 21:26:42 +0000 | [diff] [blame] | 155 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 156 | if(conn == NULL) { |
| 157 | return 0; |
| 158 | } |
| 159 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 160 | s.port = port; |
| 161 | strncpy(s.file, file, sizeof(s.file)); |
| 162 | strncpy(s.host, host, sizeof(s.host)); |
| 163 | |
| 164 | init_connection(); |
| 165 | return 1; |
| 166 | } |
| 167 | /*-----------------------------------------------------------------------------------*/ |
adamdunkels | 873b6c7 | 2003-08-09 13:31:54 +0000 | [diff] [blame] | 168 | static unsigned char * CC_FASTCALL |
| 169 | copy_string(unsigned char *dest, |
adamdunkels | 8d1e073 | 2003-09-04 19:35:00 +0000 | [diff] [blame] | 170 | const unsigned char *src, unsigned char len) |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 171 | { |
| 172 | return strcpy(dest, src) + len; |
| 173 | } |
| 174 | /*-----------------------------------------------------------------------------------*/ |
| 175 | static void |
| 176 | senddata(void) |
| 177 | { |
| 178 | u16_t len; |
| 179 | char *getrequest; |
| 180 | char *cptr; |
| 181 | |
| 182 | if(s.getrequestleft > 0) { |
| 183 | cptr = getrequest = (char *)uip_appdata; |
| 184 | |
| 185 | cptr = copy_string(cptr, http_get, sizeof(http_get) - 1); |
| 186 | cptr = copy_string(cptr, s.file, strlen(s.file)); |
| 187 | *cptr++ = ISO_space; |
| 188 | cptr = copy_string(cptr, http_10, sizeof(http_10) - 1); |
| 189 | |
| 190 | cptr = copy_string(cptr, http_crnl, sizeof(http_crnl) - 1); |
| 191 | |
| 192 | cptr = copy_string(cptr, http_host, sizeof(http_host) - 1); |
| 193 | cptr = copy_string(cptr, s.host, strlen(s.host)); |
| 194 | cptr = copy_string(cptr, http_crnl, sizeof(http_crnl) - 1); |
| 195 | |
adamdunkels | ece2177 | 2003-06-30 23:23:12 +0000 | [diff] [blame] | 196 | cptr = copy_string(cptr, http_user_agent_fields, |
adamdunkels | 09c3c76 | 2003-07-31 23:32:04 +0000 | [diff] [blame] | 197 | strlen(http_user_agent_fields)); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 198 | |
| 199 | len = s.getrequestleft > uip_mss()? |
| 200 | uip_mss(): |
| 201 | s.getrequestleft; |
| 202 | uip_send(&(getrequest[s.getrequestptr]), len); |
| 203 | } |
| 204 | } |
| 205 | /*-----------------------------------------------------------------------------------*/ |
| 206 | static void |
| 207 | acked(void) |
| 208 | { |
| 209 | u16_t len; |
| 210 | |
| 211 | if(s.getrequestleft > 0) { |
| 212 | len = s.getrequestleft > uip_mss()? |
| 213 | uip_mss(): |
| 214 | s.getrequestleft; |
| 215 | s.getrequestleft -= len; |
| 216 | s.getrequestptr += len; |
| 217 | } |
| 218 | } |
| 219 | /*-----------------------------------------------------------------------------------*/ |
| 220 | static u16_t |
| 221 | parse_statusline(u16_t len) |
| 222 | { |
| 223 | char *cptr; |
| 224 | |
| 225 | while(len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline)) { |
| 226 | s.httpheaderline[s.httpheaderlineptr] = *uip_appdata; |
| 227 | ++uip_appdata; |
| 228 | --len; |
| 229 | if(s.httpheaderline[s.httpheaderlineptr] == ISO_nl) { |
| 230 | |
| 231 | if((strncmp(s.httpheaderline, http_10, |
| 232 | sizeof(http_10) - 1) == 0) || |
| 233 | (strncmp(s.httpheaderline, http_11, |
| 234 | sizeof(http_11) - 1) == 0)) { |
| 235 | cptr = &(s.httpheaderline[9]); |
| 236 | s.httpflag = HTTPFLAG_NONE; |
| 237 | if(strncmp(cptr, http_200, sizeof(http_200) - 1) == 0) { |
| 238 | /* 200 OK */ |
| 239 | s.httpflag = HTTPFLAG_OK; |
| 240 | } else if(strncmp(cptr, http_301, sizeof(http_301) - 1) == 0 || |
| 241 | strncmp(cptr, http_302, sizeof(http_302) - 1) == 0) { |
| 242 | /* 301 Moved permanently or 302 Found. Location: header line |
| 243 | will contain thw new location. */ |
| 244 | s.httpflag = HTTPFLAG_MOVED; |
| 245 | } else { |
| 246 | s.httpheaderline[s.httpheaderlineptr - 1] = 0; |
| 247 | } |
| 248 | } else { |
| 249 | uip_abort(); |
| 250 | webclient_aborted(); |
| 251 | return 0; |
| 252 | } |
| 253 | |
| 254 | /* We're done parsing the status line, so we reset the pointer |
| 255 | and start parsing the HTTP headers.*/ |
| 256 | s.httpheaderlineptr = 0; |
| 257 | s.state = WEBCLIENT_STATE_HEADERS; |
| 258 | break; |
| 259 | } else { |
| 260 | ++s.httpheaderlineptr; |
| 261 | } |
| 262 | } |
| 263 | return len; |
| 264 | } |
| 265 | /*-----------------------------------------------------------------------------------*/ |
adamdunkels | e6a3f18 | 2003-08-22 19:22:58 +0000 | [diff] [blame] | 266 | static char |
adamdunkels | 8d1e073 | 2003-09-04 19:35:00 +0000 | [diff] [blame] | 267 | casecmp(char *str1, const char *str2, char len) |
adamdunkels | e6a3f18 | 2003-08-22 19:22:58 +0000 | [diff] [blame] | 268 | { |
| 269 | static char c; |
| 270 | |
| 271 | while(len > 0) { |
| 272 | c = *str1; |
| 273 | /* Force lower-case characters. */ |
| 274 | if(c & 0x40) { |
| 275 | c |= 0x20; |
| 276 | } |
| 277 | if(*str2 != c) { |
| 278 | return 1; |
| 279 | } |
| 280 | ++str1; |
| 281 | ++str2; |
| 282 | --len; |
| 283 | } |
| 284 | return 0; |
| 285 | } |
| 286 | /*-----------------------------------------------------------------------------------*/ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 287 | static u16_t |
| 288 | parse_headers(u16_t len) |
| 289 | { |
| 290 | char *cptr; |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 291 | static unsigned char i; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 292 | |
| 293 | while(len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline)) { |
| 294 | s.httpheaderline[s.httpheaderlineptr] = *uip_appdata; |
| 295 | ++uip_appdata; |
| 296 | --len; |
| 297 | if(s.httpheaderline[s.httpheaderlineptr] == ISO_nl) { |
| 298 | /* We have an entire HTTP header line in s.httpheaderline, so |
| 299 | we parse it. */ |
| 300 | if(s.httpheaderline[0] == ISO_cr) { |
| 301 | /* This was the last header line (i.e., and empty "\r\n"), so |
| 302 | we are done with the headers and proceed with the actual |
| 303 | data. */ |
| 304 | s.state = WEBCLIENT_STATE_DATA; |
| 305 | return len; |
| 306 | } |
| 307 | |
| 308 | s.httpheaderline[s.httpheaderlineptr - 1] = 0; |
adamdunkels | e6a3f18 | 2003-08-22 19:22:58 +0000 | [diff] [blame] | 309 | /* Check for specific HTTP header fields. */ |
| 310 | if(casecmp(s.httpheaderline, http_content_type, |
| 311 | sizeof(http_content_type) - 1) == 0) { |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 312 | /* Found Content-type field. */ |
| 313 | cptr = strchr(s.httpheaderline, ';'); |
| 314 | if(cptr != NULL) { |
| 315 | *cptr = 0; |
| 316 | } |
| 317 | strncpy(s.mimetype, s.httpheaderline + |
| 318 | sizeof(http_content_type) - 1, sizeof(s.mimetype)); |
adamdunkels | e6a3f18 | 2003-08-22 19:22:58 +0000 | [diff] [blame] | 319 | } else if(casecmp(s.httpheaderline, http_location, |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 320 | sizeof(http_location) - 1) == 0) { |
adamdunkels | 37ac5f2 | 2003-08-29 20:35:46 +0000 | [diff] [blame] | 321 | cptr = s.httpheaderline + |
| 322 | sizeof(http_location) - 1; |
| 323 | |
| 324 | if(strncmp(cptr, http_http, 7) == 0) { |
| 325 | cptr += 7; |
| 326 | for(i = 0; i < s.httpheaderlineptr - 7; ++i) { |
| 327 | if(*cptr == 0 || |
| 328 | *cptr == '/' || |
| 329 | *cptr == ' ' || |
| 330 | *cptr == ':') { |
| 331 | s.host[i] = 0; |
| 332 | break; |
| 333 | } |
| 334 | s.host[i] = *cptr; |
| 335 | ++cptr; |
| 336 | } |
| 337 | } |
| 338 | strncpy(s.file, cptr, sizeof(s.file)); |
adamdunkels | 25d2dbf | 2003-09-04 23:06:53 +0000 | [diff] [blame] | 339 | /* s.file[s.httpheaderlineptr - i] = 0;*/ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | |
| 343 | /* We're done parsing, so we reset the pointer and start the |
| 344 | next line. */ |
| 345 | s.httpheaderlineptr = 0; |
| 346 | } else { |
| 347 | ++s.httpheaderlineptr; |
| 348 | } |
| 349 | } |
| 350 | return len; |
| 351 | } |
| 352 | /*-----------------------------------------------------------------------------------*/ |
| 353 | static void |
| 354 | newdata(void) |
| 355 | { |
| 356 | u16_t len; |
| 357 | |
| 358 | len = uip_datalen(); |
| 359 | |
| 360 | if(s.state == WEBCLIENT_STATE_STATUSLINE) { |
| 361 | len = parse_statusline(len); |
| 362 | } |
| 363 | |
| 364 | if(s.state == WEBCLIENT_STATE_HEADERS && len > 0) { |
| 365 | len = parse_headers(len); |
| 366 | } |
| 367 | |
| 368 | if(len > 0 && s.state == WEBCLIENT_STATE_DATA && |
| 369 | s.httpflag != HTTPFLAG_MOVED) { |
| 370 | webclient_datahandler((char *)uip_appdata, len); |
| 371 | } |
| 372 | } |
| 373 | /*-----------------------------------------------------------------------------------*/ |
adamdunkels | 46cd143 | 2004-07-04 17:50:39 +0000 | [diff] [blame] | 374 | void |
| 375 | webclient_appcall(void *state) |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 376 | { |
adamdunkels | e3fa8fa | 2003-06-30 21:26:42 +0000 | [diff] [blame] | 377 | if(uip_connected()) { |
| 378 | s.timer = 0; |
| 379 | s.state = WEBCLIENT_STATE_STATUSLINE; |
| 380 | senddata(); |
| 381 | webclient_connected(); |
adamdunkels | 46cd143 | 2004-07-04 17:50:39 +0000 | [diff] [blame] | 382 | tcp_markconn(uip_conn, &s); |
adamdunkels | e3fa8fa | 2003-06-30 21:26:42 +0000 | [diff] [blame] | 383 | return; |
| 384 | } |
| 385 | |
adamdunkels | e2987b0 | 2003-11-27 15:47:11 +0000 | [diff] [blame] | 386 | if(uip_timedout()) { |
| 387 | webclient_timedout(); |
| 388 | } |
adamdunkels | e3fa8fa | 2003-06-30 21:26:42 +0000 | [diff] [blame] | 389 | |
| 390 | if(state == NULL) { |
| 391 | uip_abort(); |
| 392 | return; |
| 393 | } |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 394 | |
| 395 | if(s.state == WEBCLIENT_STATE_CLOSE) { |
| 396 | webclient_closed(); |
| 397 | uip_abort(); |
| 398 | return; |
adamdunkels | e2987b0 | 2003-11-27 15:47:11 +0000 | [diff] [blame] | 399 | } |
adamdunkels | e3fa8fa | 2003-06-30 21:26:42 +0000 | [diff] [blame] | 400 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 401 | if(uip_aborted()) { |
| 402 | webclient_aborted(); |
| 403 | } |
adamdunkels | e2987b0 | 2003-11-27 15:47:11 +0000 | [diff] [blame] | 404 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 405 | |
| 406 | if(uip_acked()) { |
| 407 | s.timer = 0; |
| 408 | acked(); |
| 409 | } |
| 410 | if(uip_newdata()) { |
| 411 | s.timer = 0; |
| 412 | newdata(); |
| 413 | } |
| 414 | if(uip_rexmit() || |
| 415 | uip_newdata() || |
| 416 | uip_acked()) { |
| 417 | senddata(); |
| 418 | } else if(uip_poll()) { |
| 419 | ++s.timer; |
| 420 | if(s.timer == WEBCLIENT_TIMEOUT) { |
| 421 | webclient_timedout(); |
| 422 | uip_abort(); |
| 423 | return; |
| 424 | } |
| 425 | /* senddata();*/ |
| 426 | } |
| 427 | |
| 428 | if(uip_closed()) { |
adamdunkels | 46cd143 | 2004-07-04 17:50:39 +0000 | [diff] [blame] | 429 | tcp_markconn(uip_conn, NULL); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 430 | if(s.httpflag != HTTPFLAG_MOVED) { |
| 431 | /* Send NULL data to signal EOF. */ |
| 432 | webclient_datahandler(NULL, 0); |
| 433 | } else { |
adamdunkels | 37ac5f2 | 2003-08-29 20:35:46 +0000 | [diff] [blame] | 434 | /* conn = uip_connect(uip_conn->ripaddr, s.port); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 435 | if(conn != NULL) { |
| 436 | dispatcher_markconn(conn, NULL); |
| 437 | init_connection(); |
adamdunkels | 37ac5f2 | 2003-08-29 20:35:46 +0000 | [diff] [blame] | 438 | }*/ |
| 439 | if(resolv_lookup(s.host) == NULL) { |
| 440 | resolv_query(s.host); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 441 | } |
adamdunkels | 37ac5f2 | 2003-08-29 20:35:46 +0000 | [diff] [blame] | 442 | webclient_get(s.host, s.port, s.file); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 443 | } |
| 444 | } |
| 445 | } |
| 446 | /*-----------------------------------------------------------------------------------*/ |