Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Commit

Permalink
Fix IPRO and missing Content-Length headers in 32-bit builds. (#1196)
Browse files Browse the repository at this point in the history
  • Loading branch information
hillsp authored and crowell committed Jul 21, 2016
1 parent ff89697 commit 21f9b5c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/ngx_base_fetch.cc
Expand Up @@ -12,9 +12,12 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author: jefftk@google.com (Jeff Kaufman)
*/

// Author: jefftk@google.com (Jeff Kaufman)
#include "ngx_pagespeed.h" // Must come first, see comments in CollectHeaders.

#include <unistd.h> //for usleep

#include "ngx_base_fetch.h"
Expand Down Expand Up @@ -249,6 +252,13 @@ ngx_int_t NgxBaseFetch::CollectAccumulatedWrites(ngx_chain_t** link_ptr) {
}

ngx_int_t NgxBaseFetch::CollectHeaders(ngx_http_headers_out_t* headers_out) {
// nginx defines _FILE_OFFSET_BITS to 64, which changes the size of off_t.
// If a standard header is accidentally included before the nginx header,
// on a 32-bit system off_t will be 4 bytes and we don't assign all the
// bits of content_length_n. Sanity check that did not happen.
// This could use static_assert, but this file is not built with --std=c++11.
bool sanity_check_off_t[sizeof(off_t) == 8 ? 1 : -1] __attribute__ ((unused));

const ResponseHeaders* pagespeed_headers = response_headers();

if (content_length_known()) {
Expand Down
3 changes: 2 additions & 1 deletion src/ngx_pagespeed.cc
Expand Up @@ -466,7 +466,8 @@ void copy_response_headers_from_ngx(const ngx_http_request_t* r,

// When we don't have a date header, set one with the current time.
if (headers->Lookup1(HttpAttributes::kDate) == NULL) {
headers->SetDate(ngx_current_msec);
PosixTimer timer;
headers->SetDate(timer.NowMs());
}

// TODO(oschaaf): ComputeCaching should be called in setupforhtml()?
Expand Down

0 comments on commit 21f9b5c

Please sign in to comment.