]> Nishi Git Mirror - libw3.git/commitdiff
redirect fix
authornishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Fri, 26 Jan 2024 12:45:56 +0000 (12:45 +0000)
committernishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Fri, 26 Jan 2024 12:45:56 +0000 (12:45 +0000)
git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@93 d27a3e52-49c5-7645-884c-6793ebffc270

Library/Core.c
Library/HTTP.c
Library/W3Core.h
W3Version.h.p

index 484caf1f2e8335bc21560d8c46501032cebbe3ab..674c2ff8da1b9cef3d05d817916fa18b14c9e848 100644 (file)
@@ -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;
index cf9f93c87346b991b8d2cf30831e36fab6538af8..13d3405e358cf14986e6c650ed3831e89faddbc1 100644 (file)
@@ -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);
 }
index 3eb67f29b0cf24dfaa5c57eab7ffc50483ddfa2a..3fb33d2736330429f9f576d762de667a0136e869 100644 (file)
@@ -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 */
index ec9dfd563f59ad12f920a3c17109dfec14b61b7d..553d7a17130a416dbfcc00bafd7ebee60c819f10 100644 (file)
@@ -6,7 +6,7 @@
 extern "C" {
 #endif
 
-#define LIBW3_VERSION "1.5A" \
+#define LIBW3_VERSION "1.5B" \
 SUFFIX
 
 #ifdef __cplusplus