src/ngx_fetch.cc
// When the fetch sends the request completely, it will hook the read event,
// and prepare to parse the response. Timer set in Init() is still in effect.
When the fetch sends the request completely, it will hook the read event,
and prepare to parse the response. Timer set in Init() is still in effect.
When the fetch sends the request completely it will hook the read event and prepare to parse the response . Timer set in Init () is still in effect .
void NgxFetch::ConnectionWriteHandler(ngx_event_t* wev) {
  ngx_connection_t* c = static_cast<ngx_connection_t*>(wev->data);
  NgxFetch* fetch = static_cast<NgxFetch*>(c->data);
  ngx_buf_t* out = fetch->out_;
  bool ok = true;
  while (wev->ready && out->pos < out->last) {
    int n = c->send(c, out->pos, out->last - out->pos);
    ngx_log_error(NGX_LOG_DEBUG, fetch->log_, 0,
                  "NgxFetch %p: ConnectionWriteHandler "
                  "send result %d", fetch, n);
    if (n >= 0) {
      out->pos += n;
    } else if (n == NGX_AGAIN) {
      break;
    } else {
      ok = false;
      break;
    }
  }
  if (ok) {
    if (out->pos == out->last) {
      ok = ngx_handle_read_event(c->read, 0) == NGX_OK;
    } else {
      ok = ngx_handle_write_event(c->write, 0) == NGX_OK;
    }
  }
  if (!ok) {
    fetch->message_handler()->Message(
        kWarning, "NgxFetch %p: failed to hook next event", fetch);
    c->error = 1;
    fetch->CallbackDone(false);
  }
}
void NgxFetch :: ConnectionWriteHandler ( ngx_event_t * wev ) { ngx_connection_t * c = static_cast < ngx_connection_t * > ( wev -> data ) ; NgxFetch * fetch = static_cast < NgxFetch * > ( c -> data ) ; ngx_buf_t * out = fetch -> out_ ; bool ok = true ; while ( wev -> ready && out -> pos < out -> last ) { int n = c -> send ( c , out -> pos , out -> last - out -> pos ) ; ngx_log_error ( NGX_LOG_DEBUG , fetch -> log_ , 0 , " " " " , fetch , n ) ; if ( n >= 0 ) { out -> pos += n ; } else if ( n == NGX_AGAIN ) { break ; } else { ok = false ; break ; } } if ( ok ) { if ( out -> pos == out -> last ) { ok = ngx_handle_read_event ( c -> read , 0 ) == NGX_OK ; } else { ok = ngx_handle_write_event ( c -> write , 0 ) == NGX_OK ; } } if ( ! ok ) { fetch -> message_handler ( ) -> Message ( kWarning , " " , fetch ) ; c -> error = 1 ; fetch -> CallbackDone ( false ) ; } }
When the fetch sends the request completely, it will hook the read event,
and prepare to parse the response.
When the fetch sends the request completely it will hook the read event and prepare to parse the response .