Skip to content

Commit a07aa52

Browse files
committed
as
1 parent b405ba9 commit a07aa52

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

src/server/server/fdefine.request_execution.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@ void private_CWebServer_execute_request(CwebServer *self,int socket,const char *
4444
}
4545

4646

47-
if (self->allow_cors)
48-
{
47+
48+
if (!response && self->allow_cors){
4949
if (strcmp(request->method,"OPTIONS") == 0) {
50-
51-
50+
5251
response = newCwebHttpResponse();
5352
CwebHttpResponse_add_header(response,"Access-Control-Allow-Origin","*");
5453
CwebHttpResponse_add_header(response,"Access-Control-Allow-Methods","*");
@@ -66,17 +65,18 @@ void private_CWebServer_execute_request(CwebServer *self,int socket,const char *
6665
if(!response){
6766
//lambda que o usuario passa
6867
response = self->request_handler(request);
68+
if(self->allow_cors){
69+
// Adiciona os cabeçalhos CORS à resposta
70+
CwebHttpResponse_add_header(response,"Access-Control-Allow-Origin","*");
71+
CwebHttpResponse_add_header(response,"Access-Control-Allow-Methods","*");
72+
CwebHttpResponse_add_header(response,"Access-Control-Allow-Headers","*");
73+
}
6974
}
7075

71-
if(response && self->allow_cors){
72-
// Adiciona os cabeçalhos CORS à resposta
73-
CwebHttpResponse_add_header(response,"Access-Control-Allow-Origin","*");
74-
CwebHttpResponse_add_header(response,"Access-Control-Allow-Methods","*");
75-
CwebHttpResponse_add_header(response,"Access-Control-Allow-Headers","*");
76-
}
77-
cweb_print("executed client lambda\n");
7876

7977

78+
79+
8080
//means that the main function respond nothing
8181
if (response == NULL){
8282

0 commit comments

Comments
 (0)