This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

http client fixed.


o The abbreviation of '/' is allowed.
o Fixed HTTP error processing.

Index: load.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/load.c,v
retrieving revision 1.24
diff -c -r1.24 load.c
*** load.c	29 May 2002 18:28:34 -0000	1.24
--- load.c	15 Jun 2002 14:54:32 -0000
***************
*** 644,649 ****
--- 644,653 ----
  #ifdef CYGSEM_REDBOOT_NET_HTTP_DOWNLOAD
  	} else if (strcasecmp(mode_str, "http") == 0) {
              mode = MODE_HTTP;
+             if (!have_net) {
+                 diag_printf("HTTP mode requires a working network\n");
+                 return;
+             }
  #endif
  #ifdef CYGPKG_REDBOOT_NETWORKING
          } else if (strcasecmp(mode_str, "tftp") == 0) {
***************
*** 772,777 ****
--- 776,782 ----
              *mp++ = res;
          }
          end = (unsigned long) mp;
+ 	err = getc_info.err;
  
          // Save load base/top
          load_address = base;
***************
*** 813,818 ****
--- 818,825 ----
  #ifdef CYGSEM_REDBOOT_NET_HTTP_DOWNLOAD
        case MODE_HTTP:
          http_stream_close(&err);
+ 	if (err > 0)
+ 	    diag_printf("Can't load '%s': %s\n", filename, http_error(err));
  	break;
  #endif
  #ifdef CYGPKG_REDBOOT_NETWORKING
Index: net/http_client.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/net/http_client.c,v
retrieving revision 1.1
diff -c -r1.1 http_client.c
*** net/http_client.c	23 May 2002 23:08:35 -0000	1.1
--- net/http_client.c	15 Jun 2002 14:54:32 -0000
***************
*** 85,97 ****
  {
      int res;
      struct _stream *s = &http_stream;
  
      server->sin_port = 80;  // HTTP port
      if ((res = __tcp_open(&s->sock, server, get_port++, 5000, err)) < 0) {
          *err = HTTP_OPEN;
          return -1;
      }
!     diag_sprintf(s->data, "GET %s HTTP 1.0\r\n\r\n", filename);
      __tcp_write_block(&s->sock, s->data, strlen(s->data));    
      s->avail = 0;
      s->open = true;
--- 85,102 ----
  {
      int res;
      struct _stream *s = &http_stream;
+     char root;
  
      server->sin_port = 80;  // HTTP port
      if ((res = __tcp_open(&s->sock, server, get_port++, 5000, err)) < 0) {
          *err = HTTP_OPEN;
          return -1;
      }
!     if (filename[0] == '/')
! 	root = ' ';
!     else
! 	root = '/';
!     diag_sprintf(s->data, "GET %c%s HTTP 1.0\r\n\r\n", root, filename);
      __tcp_write_block(&s->sock, s->data, strlen(s->data));    
      s->avail = 0;
      s->open = true;
***************
*** 127,149 ****
          while (s->avail == 0) {
              // Need to wait for some data to arrive
              __tcp_poll();
-             if (s->sock.state != _ESTABLISHED) {
-                 if (s->sock.state == _CLOSE_WAIT) {
-                     // This connection is breaking
-                     if (s->sock.data_bytes == 0 && s->sock.rxcnt == 0) {
-                         __tcp_close(&s->sock);
-                         return total;
-                     }
-                 }
-                 if (s->sock.state == _CLOSED) {
-                     // The connection is gone
-                     s->open = false;
-                     
-                     return -1;
-                 }
-                 *err = HTTP_IO;
-                 return -1;
-             }
              s->actual_len = __tcp_read(&s->sock, s->data, sizeof(s->data));
              if (s->actual_len > 0) {
                  s->bufp = s->data;
--- 132,137 ----
***************
*** 202,207 ****
--- 190,213 ----
                      }
                  }
              } else if (s->actual_len < 0) {
+                 *err = HTTP_IO;
+                 return -1;
+             }
+             if (s->sock.state != _ESTABLISHED) {
+                 if (s->sock.state == _CLOSE_WAIT) {
+                     // This connection is breaking
+                     if (s->sock.data_bytes == 0 && s->sock.rxcnt == 0) {
+                         __tcp_close(&s->sock);
+ 			break;
+                     }
+                 }
+                 if (s->sock.state == _CLOSED) {
+                     // The connection is gone
+                     s->open = false;
+ 		    /* stream end */
+ 		    len = 0;
+                     break ;
+                 }
                  *err = HTTP_IO;
                  return -1;
              }

-- 
Yoshinori Sato
<qzb04471@nifty.ne.jp>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]