main/ims_ota.c
/* resolve a packet from http socket
 * return true if packet including \r\n\r\n that means http packet header finished, start to receive packet body
 * otherwise return false
 */
resolve a packet from http socket
return true if packet including \r\n\r\n that means http packet header finished, start to receive packet body
otherwise return false
resolve a packet from http socket return true if packet including \ r \ n \ r \ n that means http packet header finished start to receive packet body otherwise return false
bool read_past_http_header(char text[], int total_len, esp_ota_handle_t out_handle)
{
    int i = 0, i_read_len = 0;
    while (text[i] != 0 && i < total_len) {
        i_read_len = read_until(&text[i], '\n', total_len);
        if (i_read_len == 2) {
            int i_write_len = total_len - (i + 2);
            memset(ota_write_data, 0, BUFFSIZE);
            memcpy(ota_write_data, &(text[i + 2]), i_write_len);
            esp_err_t err = esp_ota_write( out_handle, (const void *)ota_write_data, i_write_len);
            if (err != ESP_OK) {
                ESP_LOGE(TAG, "Error: esp_ota_write failed! err=0x%x", err);
                return false;
            } else {
                ESP_LOGI(TAG, "esp_ota_write header OK");
                binary_file_length += i_write_len;
            }
            return true;
        }
        i += i_read_len;
    }
    return false;
}
bool read_past_http_header ( char text [ ] , int total_len , esp_ota_handle_t out_handle ) { int i = 0 , i_read_len = 0 ; while ( text [ i ] != 0 && i < total_len ) { i_read_len = read_until ( & text [ i ] , ' \n ' , total_len ) ; if ( i_read_len == 2 ) { int i_write_len = total_len - ( i + 2 ) ; memset ( ota_write_data , 0 , BUFFSIZE ) ; memcpy ( ota_write_data , & ( text [ i + 2 ] ) , i_write_len ) ; esp_err_t err = esp_ota_write ( out_handle , ( const void * ) ota_write_data , i_write_len ) ; if ( err != ESP_OK ) { ESP_LOGE ( TAG , " " , err ) ; return false ; } else { ESP_LOGI ( TAG , " " ) ; binary_file_length += i_write_len ; } return true ; } i += i_read_len ; } return false ; }
resolve a packet from http socket
 return true if packet including \r\n\r\n that means http packet header finished, start to receive packet body
 otherwise return false
resolve a packet from http socket return true if packet including \ r \ n \ r \ n that means http packet header finished start to receive packet body otherwise return false
/* i means current position */ // if we resolve \r\n line,we think packet header is finished /*copy first http packet body to write buffer*/