ESPAsyncWebServer icon indicating copy to clipboard operation
ESPAsyncWebServer copied to clipboard

Bug safari with Content-Encoding: gzip and Content-Disposition

Open xlyric opened this issue 2 years ago • 1 comments

hi,

the header Content-Disposition create a bug in this case : explorer : Safari

html page called in mode gzip ( HTTP compress ) ( GET /index.html HTTP/1.1 Host: xxx Accept-Encoding: gzip )

the librairie return a wrong"Content-Disposition" and expose a file who was not rerouted ex :

void compress_html(AsyncWebServerRequest *request,String filefs , String format ) {
      AsyncWebServerResponse *response = request->beginResponse(SPIFFS, filefs, format);
      response->addHeader("Content-Encoding", "gzip");
      response->addHeader("Cache-Control", "max-age=604800");
      request->send(response);
}

 server.on("/",HTTP_GET, [](AsyncWebServerRequest *request){
    if(SPIFFS.exists("/index.html.gz")){
      compress_html(request,"/index-ap.html.gz", "text/html");
    }

the response header is wrong

Accept-Ranges: none
Cache-Control: max-age=604800
Connection: close
Content-Disposition: inline; filename="index.html.gz"
Content-Encoding: gzip
Content-Length: 3890
Content-Type: text/html

and Content-Disposition: is not usefull in this case.

on all navigator except safari, the navigator skip this line. Safari try to call the wrong file.

xlyric avatar Apr 27 '23 07:04 xlyric

@jesserockz : FYI @xlyric also warned me about this bug and the fix is something else:

https://github.com/mathieucarbou/ESPAsyncWebServer/commit/cfbe38ca957e84f9724b51cf6622d06b21daa674

No filename after inline in Content-Disposition header according to RFC2183.

It is fixes in my fork https://github.com/mathieucarbou/ESPAsyncWebServer

mathieucarbou avatar Jun 20 '24 07:06 mathieucarbou