]> Nishi Git Mirror - libw3.git/commitdiff
http data works
authornishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Sun, 21 Jan 2024 14:16:53 +0000 (14:16 +0000)
committernishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Sun, 21 Jan 2024 14:16:53 +0000 (14:16 +0000)
git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@37 d27a3e52-49c5-7645-884c-6793ebffc270

Example/fetch.c
Library/HTTP.c

index 5040dc3c79b0f4487f91feb68224d24c3e0eb960..64afe18d829b5153927fa85b21fc110ae7202728 100644 (file)
@@ -10,7 +10,7 @@
 #include <string.h>
 #include <unistd.h>
 
-void fetch_data(struct W3* w3, size_t size, char* data){
+void fetch_data(struct W3* w3, char* data, size_t size){
        write(1, data, size);
 }
 
index cf211d3d11ba67655f781e0aef7b5990d07c316c..39e379b8364e103a27267d65221e9d4fdd2dbdbc 100644 (file)
@@ -126,8 +126,16 @@ void __W3_HTTP_Request(struct W3* w3){
                                                        }
                                                }
                                                free(headers);
+                                               phase++;
                                        }
                                }
+                       }else if(phase == 2){
+                               void* funcptr = __W3_Get_Event(w3, "data");
+                               if(funcptr != NULL){
+                                       void(*func)(struct W3* w3, char*, size_t) = (void(*)(struct W3* w3, char*, size_t))funcptr;
+                                       func(w3, buf + i, l - i);
+                               }
+                               break;
                        }
                }
        }