mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-25 13:19:59 -04:00
Fix bug where I.E9 could not access kiwix-serve content due to deflate.
This commit is contained in:
parent
6d044853f4
commit
58fdb1d52f
@ -24,16 +24,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#if (_MSC_VER < 1600)
|
|
||||||
#include "stdint4win.h"
|
|
||||||
#endif
|
|
||||||
#include <winsock2.h>
|
|
||||||
#include <WS2tcpip.h> // otherwise socklen_t is not a recognized type
|
#include <WS2tcpip.h> // otherwise socklen_t is not a recognized type
|
||||||
//#include <Windows.h> // otherwise int is not a recognized type
|
#include <stdint4win.h>
|
||||||
typedef int off_t;
|
#include <winsock2.h>
|
||||||
|
#include <Windows.h> // otherwise int is not a recognized type
|
||||||
typedef SSIZE_T ssize_t;
|
typedef SSIZE_T ssize_t;
|
||||||
typedef UINT64 uint64_t;
|
typedef int off_t;
|
||||||
typedef UINT16 uint16_t;
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
}
|
}
|
||||||
@ -157,6 +153,11 @@ static int accessHandlerCallback(void *cls,
|
|||||||
size_t * upload_data_size,
|
size_t * upload_data_size,
|
||||||
void ** ptr) {
|
void ** ptr) {
|
||||||
|
|
||||||
|
/* Debug */
|
||||||
|
if (isVerbose()) {
|
||||||
|
std::cout << "Requesting " << url << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
/* Unexpected method */
|
/* Unexpected method */
|
||||||
if (0 != strcmp(method, "GET"))
|
if (0 != strcmp(method, "GET"))
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
@ -168,11 +169,6 @@ static int accessHandlerCallback(void *cls,
|
|||||||
return MHD_YES;
|
return MHD_YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Debug */
|
|
||||||
if (isVerbose()) {
|
|
||||||
std::cout << "Requesting (" << method << ") " << url << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if the response can be compressed */
|
/* Check if the response can be compressed */
|
||||||
const string acceptEncodingHeaderValue = MHD_lookup_connection_value(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_ACCEPT_ENCODING) ?
|
const string acceptEncodingHeaderValue = MHD_lookup_connection_value(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_ACCEPT_ENCODING) ?
|
||||||
MHD_lookup_connection_value(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_ACCEPT_ENCODING) : "";
|
MHD_lookup_connection_value(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_ACCEPT_ENCODING) : "";
|
||||||
@ -355,6 +351,13 @@ static int accessHandlerCallback(void *cls,
|
|||||||
|
|
||||||
compress(compr, &comprLen, (const Bytef*)(content.data()), contentLength);
|
compress(compr, &comprLen, (const Bytef*)(content.data()), contentLength);
|
||||||
|
|
||||||
|
/* /!\ Internet Explorer has a bug with deflate compression.
|
||||||
|
It can not handle the first two bytes (compression headers)
|
||||||
|
We need to chunk them off (move the content 2bytes)
|
||||||
|
It has no incidence on other browsers */
|
||||||
|
compr++;
|
||||||
|
compr++;
|
||||||
|
|
||||||
content = string((char *)compr, comprLen);
|
content = string((char *)compr, comprLen);
|
||||||
contentLength = comprLen;
|
contentLength = comprLen;
|
||||||
|
|
||||||
@ -474,10 +477,9 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
/* Setup the library manager and get the list of books */
|
/* Setup the library manager and get the list of books */
|
||||||
if (libraryFlag) {
|
if (libraryFlag) {
|
||||||
vector<string> libraryPaths = kiwix::split(libraryPath, ";");
|
vector<string> libraryPaths = kiwix::split(libraryPath, ":");
|
||||||
vector<string>::iterator itr;
|
vector<string>::iterator itr;
|
||||||
for ( itr = libraryPaths.begin(); itr != libraryPaths.end(); ++itr ) {
|
for ( itr = libraryPaths.begin(); itr != libraryPaths.end(); ++itr ) {
|
||||||
if (!(*itr).empty()) {
|
|
||||||
bool retVal = false;
|
bool retVal = false;
|
||||||
try {
|
try {
|
||||||
retVal = libraryManager.readFile(*itr, true);
|
retVal = libraryManager.readFile(*itr, true);
|
||||||
@ -490,7 +492,6 @@ int main(int argc, char **argv) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if the library is not empty (or only remote books)*/
|
/* Check if the library is not empty (or only remote books)*/
|
||||||
if (libraryManager.getBookCount(true, false)==0) {
|
if (libraryManager.getBookCount(true, false)==0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user