From: nishi Date: Fri, 26 Jan 2024 12:45:56 +0000 (+0000) Subject: redirect fix X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=f35fd80c2b050df20a286a1a2a141caaa4615b4c;p=libw3.git redirect fix git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@93 d27a3e52-49c5-7645-884c-6793ebffc270 --- diff --git a/Library/Core.c b/Library/Core.c index 484caf1..674c2ff 100644 --- a/Library/Core.c +++ b/Library/Core.c @@ -59,6 +59,7 @@ struct W3* W3_Create(const char* protocol, const char* hostname, int port) { w3->size = 0; w3->data = NULL; w3->readsize = 512; + w3->port = port; w3->protocol = __W3_Strdup(protocol); #ifdef SSL_SUPPORT w3->ssl = NULL; diff --git a/Library/HTTP.c b/Library/HTTP.c index cf9f93c..13d3405 100644 --- a/Library/HTTP.c +++ b/Library/HTTP.c @@ -267,13 +267,21 @@ void __W3_HTTP_Request(struct W3* w3) { ); free(w3->protocol); w3->protocol = __W3_Strdup(u->protocol); - free(w3->hostname); w3->hostname = __W3_Strdup(u->host); W3_Set_Path(w3, u->path); + w3->port = u->port; W3_Free_URL(u); - W3_Send_Request(w3); + }else if(redir[0] == '/'){ + w3->sock = __W3_DNS_Connect(w3->hostname, strcmp(w3->protocol, "https") == 0 ? true : false, w3->port +#ifdef SSL_SUPPORT + , + &w3->ssl, &w3->ssl_ctx +#endif + ); + W3_Set_Path(w3, redir); } + W3_Send_Request(w3); } if(redir != NULL) free(redir); } diff --git a/Library/W3Core.h b/Library/W3Core.h index 3eb67f2..3fb33d2 100644 --- a/Library/W3Core.h +++ b/Library/W3Core.h @@ -13,6 +13,7 @@ extern "C" { struct W3 { int sock; /* Socket */ + int port; /* Port */ char* protocol; /* As you can read from its name */ char* method; /* Used in HTTP */ char* path; /* As you can read from its name */ diff --git a/W3Version.h.p b/W3Version.h.p index ec9dfd5..553d7a1 100644 --- a/W3Version.h.p +++ b/W3Version.h.p @@ -6,7 +6,7 @@ extern "C" { #endif -#define LIBW3_VERSION "1.5A" \ +#define LIBW3_VERSION "1.5B" \ SUFFIX #ifdef __cplusplus