Beispiel #1
0
static void handle_curl_byte( const char c, p_data_ctx dctx )
{
    if ( dctx->first_line )
    {
        if ( c == 0x0A )
        {
            dctx->buffer[ dctx->data_count++ ] = 0;
            if ( !handle_first_line( dctx ) )
            {
                dctx->rc = RC(rcExe, rcBuffer, rcAccessing, rcData, rcInvalid );
                LOGERR( klogErr, dctx->rc, "server returned invalid data, possibly wrong accession/url" );
            }
            dctx->data_count = 0;
            dctx->first_line = false;
        }
        else
        {
            if ( dctx->data_count < dctx->buff_size )
                dctx->buffer[ dctx->data_count++ ] = c;
        }
    }
    else
    {
        if ( c > 0x20 )
        {
            dctx->byte_count++;
            dctx->buffer[ dctx->data_count++ ] = c;
            if ( dctx->data_count >= dctx->buff_size )
                write_curl_data( dctx );
        }
    }
}
Beispiel #2
0
static int finish_line(grpc_http_parser *parser) {
  switch (parser->state) {
    case GRPC_HTTP_FIRST_LINE:
      if (!handle_first_line(parser)) {
        return 0;
      }
      parser->state = GRPC_HTTP_HEADERS;
      break;
    case GRPC_HTTP_HEADERS:
      if (parser->cur_line_length == parser->cur_line_end_length) {
        parser->state = GRPC_HTTP_BODY;
        break;
      }
      if (!add_header(parser)) {
        return 0;
      }
      break;
    case GRPC_HTTP_BODY:
      GPR_UNREACHABLE_CODE(return 0);
  }

  parser->cur_line_length = 0;
  return 1;
}