<commit_before>#include "ZipRespSource.h"

#include <stdexcept>

#include "CommonErrorRespSource.h"
#include "detail/MimeDB.h"

using namespace HTTP;
using namespace HTTP::RespSource;

const char *Zip::Response::IdentityEncoding="identity";
const char *Zip::Response::GZipEncoding="gzip";
unsigned char Zip::Response::GZipHeaderA[10]={
	31, 139, //ID1 ID2
	8, //CM; 8: deflate
	0, //FLG
	0, 0, 0, 0, //MTIME
	2, //XFL
	255 //OS
};

Zip::Response::Response(ZipArchive::Stream *ArchS, const char *MimeType, time_t IfModifiedSince) : MyMimeType(MimeType)
{
	time_t LastModTime=ArchS->GetInfo()->LastModTime;
	Header::FormatDateTime(LastModTime,LastModifiedStr);

	if (LastModTime>IfModifiedSince)
	{
		SourceS=ArchS;
		FileSize=ArchS->GetInfo()->CompressedSize;

		if (SourceS->GetInfo()->Compression==ZipArchive::CM_DEFLATE)
		{
			//Compose a Gzip footer.
			*(unsigned int *)GzipFooterA=SourceS->GetInfo()->CRC32;
			*((unsigned int *)GzipFooterA+1)=SourceS->GetInfo()->UncompressedSize;

			CState=CS_HEADER;
			CStatePos=0;

			FileSize+=sizeof(GZipHeaderA) + sizeof(GzipFooterA);
		}
		else
			CState=CS_BODYONLY;
	}
	else
	{
		SourceS=nullptr;
		delete ArchS;
		FileSize=NotModifiedSize;
	}
}

bool Zip::Response::GetExtraHeader(unsigned int Index,
	const char **OutHeader, const char **OutHeaderEnd,<commit_msg>Zip::Response: strict aliasing warning fix<commit_after>#include "ZipRespSource.h"

#include <stdexcept>

#include "CommonErrorRespSource.h"
#include "detail/MimeDB.h"

using namespace HTTP;
using namespace HTTP::RespSource;

const char *Zip::Response::IdentityEncoding="identity";
const char *Zip::Response::GZipEncoding="gzip";
unsigned char Zip::Response::GZipHeaderA[10]={
	31, 139, //ID1 ID2
	8, //CM; 8: deflate
	0, //FLG
	0, 0, 0, 0, //MTIME
	2, //XFL
	255 //OS
};

Zip::Response::Response(ZipArchive::Stream *ArchS, const char *MimeType, time_t IfModifiedSince) : MyMimeType(MimeType)
{
	time_t LastModTime=ArchS->GetInfo()->LastModTime;
	Header::FormatDateTime(LastModTime,LastModifiedStr);

	if (LastModTime>IfModifiedSince)
	{
		SourceS=ArchS;
		FileSize=ArchS->GetInfo()->CompressedSize;

		if (SourceS->GetInfo()->Compression==ZipArchive::CM_DEFLATE)
		{
			//Compose a Gzip footer.
			unsigned int *FooterFieldA=(unsigned int *)GzipFooterA;
			FooterFieldA[0]=SourceS->GetInfo()->CRC32;
			FooterFieldA[1]=SourceS->GetInfo()->UncompressedSize;

			CState=CS_HEADER;
			CStatePos=0;

			FileSize+=sizeof(GZipHeaderA) + sizeof(GzipFooterA);
		}
		else
			CState=CS_BODYONLY;
	}
	else
	{
		SourceS=nullptr;
		delete ArchS;
		FileSize=NotModifiedSize;
	}
}

bool Zip::Response::GetExtraHeader(unsigned int Index,
	const char **OutHeader, const char **OutHeaderEnd,
{'fraction_non_alphanumeric': 0.14721189591078068, 'fraction_numerical': 0.018215613382899627, 'mean_word_length': 5.812658227848101, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6879032', 'n_tokens_mistral': 1100, 'n_tokens_neox': 981, 'n_words': 184}