main/task_http.c

changeset 61
c7b8a9931b59
parent 54
7b134c27fadb
child 64
326c38d3681b
equal deleted inserted replaced
60:f93706c82762 61:c7b8a9931b59
171 strncat(header, "Content-Encoding: gzip\r\n", 255 - strlen(header)); 171 strncat(header, "Content-Encoding: gzip\r\n", 255 - strlen(header));
172 } 172 }
173 strncat(header, "\r\n", 255 - strlen(header)); // Add last empty line. 173 strncat(header, "\r\n", 255 - strlen(header)); // Add last empty line.
174 err = netconn_write(conn, header, strlen(header), NETCONN_NOCOPY); 174 err = netconn_write(conn, header, strlen(header), NETCONN_NOCOPY);
175 if (err != ERR_OK) { 175 if (err != ERR_OK) {
176 ESP_LOGE(TAG, "%s sendfile %s%s err=%d on header write", ipstr, temp_url, (send_gz) ? ".gz":"", err); 176 ESP_LOGW(TAG, "%s sendfile %s%s err=%d on header write", ipstr, temp_url, (send_gz) ? ".gz":"", err);
177 fclose(f); 177 fclose(f);
178 return; 178 return;
179 } 179 }
180 // if (strstr(acceptEncodingBuffer, "gzip") == NULL) 180 // if (strstr(acceptEncodingBuffer, "gzip") == NULL)
181 // http_error(conn, 501, "Not implemented", "Your browser does not accept gzip-compressed data."); 181 // http_error(conn, 501, "Not implemented", "Your browser does not accept gzip-compressed data.");
190 if (bytes == 0) 190 if (bytes == 0)
191 break; 191 break;
192 192
193 err = netconn_write(conn, buff, bytes, NETCONN_NOCOPY); 193 err = netconn_write(conn, buff, bytes, NETCONN_NOCOPY);
194 if (err != ERR_OK) { 194 if (err != ERR_OK) {
195 ESP_LOGE(TAG, "%s sendfile %s%s err=%d send %u bytes of %ld bytes", ipstr, temp_url, (send_gz) ? ".gz":"", err, sentsize, filesize); 195 ESP_LOGW(TAG, "%s sendfile %s%s err=%d send %u bytes of %ld bytes", ipstr, temp_url, (send_gz) ? ".gz":"", err, sentsize, filesize);
196 break; 196 break;
197 } 197 }
198 vTaskDelay(2 / portTICK_PERIOD_MS); 198 vTaskDelay(2 / portTICK_PERIOD_MS);
199 sentsize += bytes; 199 sentsize += bytes;
200 pause++; 200 pause++;
331 netconn_set_recvtimeout(conn,1000); // allow a connection timeout of 1 second 331 netconn_set_recvtimeout(conn,1000); // allow a connection timeout of 1 second
332 err = netconn_recv(conn, &inbuf); 332 err = netconn_recv(conn, &inbuf);
333 333
334 if (err != ERR_OK) { 334 if (err != ERR_OK) {
335 if (err != ERR_TIMEOUT) { // Ignore timeout 335 if (err != ERR_TIMEOUT) { // Ignore timeout
336 ESP_LOGI(TAG,"%s error %d on read", ipstr, err); 336 ESP_LOGW(TAG,"%s error %d on read", ipstr, err);
337 } 337 }
338 netconn_close(conn); 338 netconn_close(conn);
339 netconn_delete(conn); 339 netconn_delete(conn);
340 netbuf_delete(inbuf); 340 netbuf_delete(inbuf);
341 return; 341 return;
466 466
467 do { 467 do {
468 err = netconn_accept(conn, &newconn); 468 err = netconn_accept(conn, &newconn);
469 if (err == ERR_OK) { 469 if (err == ERR_OK) {
470 if (xQueueSendToBack(client_queue,&newconn,portMAX_DELAY) != pdTRUE) { 470 if (xQueueSendToBack(client_queue,&newconn,portMAX_DELAY) != pdTRUE) {
471 ESP_LOGE(TAG, "xQueueSendToBack() queue full"); 471 ESP_LOGW(TAG, "xQueueSendToBack() queue full");
472 }; 472 };
473 } 473 }
474 vTaskDelay(5 / portTICK_PERIOD_MS); 474 vTaskDelay(5 / portTICK_PERIOD_MS);
475 } while (err == ERR_OK); 475 } while (err == ERR_OK);
476 476

mercurial