Subversion Repositories SvarDOS

Rev

Rev 328 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 328 Rev 329
Line 126... Line 126...
126
    goto SHITQUIT;
126
    goto SHITQUIT;
127
  }
127
  }
128
 
128
 
129
  /* wait for net_connect() to actually connect */
129
  /* wait for net_connect() to actually connect */
130
  for (;;) {
130
  for (;;) {
131
    int connstate = net_isconnected(sock, 1);
131
    int connstate = net_isconnected(sock);
132
    if (connstate > 0) break;
132
    if (connstate > 0) break;
133
    if (connstate < 0) {
133
    if (connstate < 0) {
134
      puts("ERROR: connection error");
134
      puts("ERROR: connection error");
135
      goto SHITQUIT;
135
      goto SHITQUIT;
136
    }
136
    }
Line 138... Line 138...
138
  }
138
  }
139
 
139
 
140
  /* socket is connected - send the http request */
140
  /* socket is connected - send the http request */
141
  snprintf((char *)buffer, sizeof(buffer), "GET %s HTTP/1.1\r\nHOST: " HOSTADDR "\r\nUSER-AGENT: pkgnet\r\nConnection: close\r\n\r\n", url);
141
  snprintf((char *)buffer, sizeof(buffer), "GET %s HTTP/1.1\r\nHOST: " HOSTADDR "\r\nUSER-AGENT: pkgnet\r\nConnection: close\r\n\r\n", url);
142
 
142
 
143
  if (net_send(sock, (char *)buffer, strlen((char *)buffer)) != (int)strlen((char *)buffer)) {
143
  if (net_send(sock, buffer, strlen((char *)buffer)) != (int)strlen((char *)buffer)) {
144
    puts("ERROR: failed to send HTTP query to remote server");
144
    puts("ERROR: failed to send HTTP query to remote server");
145
    goto SHITQUIT;
145
    goto SHITQUIT;
146
  }
146
  }
147
 
147
 
148
  lastactivity = time(NULL);
148
  lastactivity = time(NULL);
149
  for (;;) {
149
  for (;;) {
150
    int byteread = net_recv(sock, (char *)buffer, sizeof(buffer) - 1); /* -1 because I will append a NULL terminator */
150
    int byteread = net_recv(sock, buffer, sizeof(buffer) - 1); /* -1 because I will append a NULL terminator */
151
 
151
 
152
    if (byteread < 0) break; /* end of connection */
152
    if (byteread < 0) break; /* end of connection */
153
 
153
 
154
    /*  */
154
    /*  */
155
    if (byteread == 0) {
155
    if (byteread == 0) {