forked from me-no-dev/ESPAsyncWebServer
remove Access-Control-Allow-Origin
This commit is contained in:
@@ -158,7 +158,6 @@ AsyncBasicResponse::AsyncBasicResponse(int code, String contentType, String cont
|
|||||||
_contentType = "text/plain";
|
_contentType = "text/plain";
|
||||||
}
|
}
|
||||||
addHeader("Connection","close");
|
addHeader("Connection","close");
|
||||||
addHeader("Access-Control-Allow-Origin","*");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncBasicResponse::_respond(AsyncWebServerRequest *request){
|
void AsyncBasicResponse::_respond(AsyncWebServerRequest *request){
|
||||||
@@ -228,7 +227,6 @@ size_t AsyncBasicResponse::_ack(AsyncWebServerRequest *request, size_t len, uint
|
|||||||
|
|
||||||
void AsyncAbstractResponse::_respond(AsyncWebServerRequest *request){
|
void AsyncAbstractResponse::_respond(AsyncWebServerRequest *request){
|
||||||
addHeader("Connection","close");
|
addHeader("Connection","close");
|
||||||
addHeader("Access-Control-Allow-Origin","*");
|
|
||||||
_head = _assembleHead(request->version());
|
_head = _assembleHead(request->version());
|
||||||
_state = RESPONSE_HEADERS;
|
_state = RESPONSE_HEADERS;
|
||||||
_ack(request, 0, 0);
|
_ack(request, 0, 0);
|
||||||
@@ -349,9 +347,8 @@ void AsyncFileResponse::_setContentType(String path){
|
|||||||
AsyncFileResponse::AsyncFileResponse(FS &fs, String path, String contentType, bool download){
|
AsyncFileResponse::AsyncFileResponse(FS &fs, String path, String contentType, bool download){
|
||||||
_code = 200;
|
_code = 200;
|
||||||
_path = path;
|
_path = path;
|
||||||
int filenameStart = path.lastIndexOf('/') + 1;
|
_content = fs.open(_path, "r");
|
||||||
char buf[26+path.length()-filenameStart];
|
_contentLength = _content.size();
|
||||||
char* filename = (char*)path.c_str() + filenameStart;
|
|
||||||
|
|
||||||
if(!download && !fs.exists(_path) && fs.exists(_path+".gz")){
|
if(!download && !fs.exists(_path) && fs.exists(_path+".gz")){
|
||||||
_path = _path+".gz";
|
_path = _path+".gz";
|
||||||
@@ -363,6 +360,10 @@ AsyncFileResponse::AsyncFileResponse(FS &fs, String path, String contentType, bo
|
|||||||
else
|
else
|
||||||
_contentType = contentType;
|
_contentType = contentType;
|
||||||
|
|
||||||
|
int filenameStart = path.lastIndexOf('/') + 1;
|
||||||
|
char buf[26+path.length()-filenameStart];
|
||||||
|
char* filename = (char*)path.c_str() + filenameStart;
|
||||||
|
|
||||||
if(download) {
|
if(download) {
|
||||||
// set filename and force download
|
// set filename and force download
|
||||||
snprintf(buf, sizeof (buf), "attachment; filename=\"%s\"", filename);
|
snprintf(buf, sizeof (buf), "attachment; filename=\"%s\"", filename);
|
||||||
@@ -372,27 +373,26 @@ AsyncFileResponse::AsyncFileResponse(FS &fs, String path, String contentType, bo
|
|||||||
}
|
}
|
||||||
addHeader("Content-Disposition", buf);
|
addHeader("Content-Disposition", buf);
|
||||||
|
|
||||||
_content = fs.open(_path, "r");
|
|
||||||
_contentLength = _content.size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncFileResponse::AsyncFileResponse(File content, String path, String contentType, bool download){
|
AsyncFileResponse::AsyncFileResponse(File content, String path, String contentType, bool download){
|
||||||
_code = 200;
|
_code = 200;
|
||||||
_content = content;
|
|
||||||
_path = path;
|
_path = path;
|
||||||
|
_content = content;
|
||||||
_contentLength = _content.size();
|
_contentLength = _content.size();
|
||||||
int filenameStart = _path.lastIndexOf('/') + 1;
|
|
||||||
char buf[26+_path.length()-filenameStart];
|
|
||||||
char* filename = (char*)_path.c_str() + filenameStart;
|
|
||||||
|
|
||||||
if(!download && String(_content.name()).endsWith(".gz"))
|
if(!download && String(_content.name()).endsWith(".gz"))
|
||||||
addHeader("Content-Encoding", "gzip");
|
addHeader("Content-Encoding", "gzip");
|
||||||
|
|
||||||
if(contentType == "")
|
if(contentType == "")
|
||||||
_setContentType(_path);
|
_setContentType(path);
|
||||||
else
|
else
|
||||||
_contentType = contentType;
|
_contentType = contentType;
|
||||||
|
|
||||||
|
int filenameStart = path.lastIndexOf('/') + 1;
|
||||||
|
char buf[26+path.length()-filenameStart];
|
||||||
|
char* filename = (char*)path.c_str() + filenameStart;
|
||||||
|
|
||||||
if(download) {
|
if(download) {
|
||||||
snprintf(buf, sizeof (buf), "attachment; filename=\"%s\"", filename);
|
snprintf(buf, sizeof (buf), "attachment; filename=\"%s\"", filename);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user