Skip to content

Commit

Permalink
Enable force encoding with provided encoding types. (#160)
Browse files Browse the repository at this point in the history
Signed-off-by: Akayeshmantha <[email protected]>
  • Loading branch information
Ayeshmantha Perera authored Sep 2, 2020
1 parent f9b8e64 commit ff10b59
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions c/httpserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -4083,11 +4083,32 @@ void respondWithUnixFile2(HttpService* service, HttpResponse* response, char* ab
#error Unknown OS
#endif
;
if (ccsid == 0) {
streamTextForFile2(response, NULL, in, ENCODING_CHUNKED, NATIVE_CODEPAGE, webCodePage, asB64);
} else {
streamTextForFile2(response, NULL, in, ENCODING_CHUNKED, ccsid, webCodePage, asB64);
}
char *forceEnabled = getQueryParam(response->request, "force");
if (ccsid == 0 && strcmp(forceEnabled, "enable")) {
char *sourceEncoding = getQueryParam(response->request, "source");
char *targetEncoding = getQueryParam(response->request, "target");
int sEncoding;
int tEncoding;
if(sourceEncoding != NULL && targetEncoding != NULL) {
int sscanfSource = sscanf(sourceEncoding, "%d", &sEncoding);
int sscanfTarget = sscanf(targetEncoding, "%d", &tEncoding);
if (sscanfSource != 1 || sscanfTarget != 1) {
respondWithError(response, HTTP_STATUS_BAD_REQUEST, "source/target encoding value parsing error.");
return;
}
streamTextForFile2(response, NULL, in, ENCODING_CHUNKED, sEncoding, tEncoding, asB64);
}
else {
respondWithError(response, HTTP_STATUS_BAD_REQUEST, "force encoding enabled make sure to pass all the requried params");
return;
}
}
else if(ccsid == 0) {
streamTextForFile2(response, NULL, in, ENCODING_CHUNKED, NATIVE_CODEPAGE, webCodePage, asB64);
}
else {
streamTextForFile2(response, NULL, in, ENCODING_CHUNKED, ccsid, webCodePage, asB64);
}

#ifdef USE_CONTINUE_RESPONSE_HACK
/* See comments above */
Expand Down

0 comments on commit ff10b59

Please sign in to comment.