src/ngx_pagespeed.cc
// If we've decided that we should record this response for future optimization
// with IPRO, then log the bytes as they come through
If we've decided that we should record this response for future optimization
with IPRO, then log the bytes as they come through
If we ' ve decided that we should record this response for future optimization with IPRO then log the bytes as they come through
ngx_int_t ps_in_place_body_filter(ngx_http_request_t* r, ngx_chain_t* in) {
  ps_request_ctx_t* ctx = ps_get_request_context(r);
  if (ctx == NULL || ctx->recorder == NULL) {
    return ngx_http_next_body_filter(r, in);
  }
  ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                 "ps in place body filter: %V", &r->uri);
  InPlaceResourceRecorder* recorder = ctx->recorder;
  for (ngx_chain_t* cl = in; cl; cl = cl->next) {
    if (ngx_buf_size(cl->buf)) {
      CHECK(ngx_buf_in_memory(cl->buf));
      StringPiece contents(reinterpret_cast<char*>(cl->buf->pos),
                           ngx_buf_size(cl->buf));
      recorder->Write(contents, recorder->handler());
    }
    if (cl->buf->flush) {
      recorder->Flush(recorder->handler());
    }
    if (cl->buf->last_buf || recorder->failed()) {
      ResponseHeaders response_headers;
      copy_response_headers_from_ngx(r, &response_headers);
      ctx->recorder->DoneAndSetHeaders(
          &response_headers,
          cl->buf->last_buf );
      ctx->recorder = NULL;
      break;
    }
  }
  return ngx_http_next_body_filter(r, in);
}
ngx_int_t ps_in_place_body_filter ( ngx_http_request_t * r , ngx_chain_t * in ) { ps_request_ctx_t * ctx = ps_get_request_context ( r ) ; if ( ctx == NULL || ctx -> recorder == NULL ) { return ngx_http_next_body_filter ( r , in ) ; } ngx_log_debug1 ( NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 , " " , & r -> uri ) ; InPlaceResourceRecorder * recorder = ctx -> recorder ; for ( ngx_chain_t * cl = in ; cl ; cl = cl -> next ) { if ( ngx_buf_size ( cl -> buf ) ) { CHECK ( ngx_buf_in_memory ( cl -> buf ) ) ; StringPiece contents ( reinterpret_cast < char * > ( cl -> buf -> pos ) , ngx_buf_size ( cl -> buf ) ) ; recorder -> Write ( contents , recorder -> handler ( ) ) ; } if ( cl -> buf -> flush ) { recorder -> Flush ( recorder -> handler ( ) ) ; } if ( cl -> buf -> last_buf || recorder -> failed ( ) ) { ResponseHeaders response_headers ; copy_response_headers_from_ngx ( r , & response_headers ) ; ctx -> recorder -> DoneAndSetHeaders ( & response_headers , cl -> buf -> last_buf ) ; ctx -> recorder = NULL ; break ; } } return ngx_http_next_body_filter ( r , in ) ; }
If we've decided that we should record this response for future optimization
with IPRO, then log the bytes as they come through
If we ' ve decided that we should record this response for future optimization with IPRO then log the bytes as they come through
/* response is complete if last_buf is set */