@@ -7,12 +7,12 @@ const Easy = curl.Easy;
77const Multi = curl .Multi ;
88const c = curl .libcurl ;
99const checkCode = curl .checkCode ;
10- const AnyWriter = std .io .AnyWriter ;
10+ const Writer = std .io .Writer ;
1111
12- fn newEasy (writer : * curl.ResizableResponseWriter , any_writer : * const AnyWriter , url : [:0 ]const u8 ) ! Easy {
12+ fn newEasy (writer : * Writer , url : [:0 ]const u8 ) ! Easy {
1313 const easy = try Easy .init (.{});
1414 try easy .setUrl (url );
15- try easy .setAnyWriter ( any_writer );
15+ try easy .setWriter ( writer );
1616 // CURLOPT_PRIVATE allows us to store a pointer to the ctx in the easy handle
1717 // so we can retrieve it later in the callback.
1818 try easy .setPrivate (writer );
@@ -28,15 +28,13 @@ pub fn main() !void {
2828 const multi = try Multi .init ();
2929 defer multi .deinit ();
3030
31- var wtr1 = curl . ResizableResponseWriter .init (allocator );
31+ var wtr1 = std . Io . Writer . Allocating .init (allocator );
3232 defer wtr1 .deinit ();
33- const any_writer1 : AnyWriter = wtr1 .asAny ();
34- var wtr2 = curl .ResizableResponseWriter .init (allocator );
33+ var wtr2 = std .Io .Writer .Allocating .init (allocator );
3534 defer wtr2 .deinit ();
36- const any_writer2 : AnyWriter = wtr2 .asAny ();
3735
38- try multi .addHandle (try newEasy (& wtr1 , & any_writer1 , "http://httpbin.org/headers" ));
39- try multi .addHandle (try newEasy (& wtr2 , & any_writer2 , "http://httpbin.org/ip" ));
36+ try multi .addHandle (try newEasy (& wtr1 . writer , "http://httpbin.org/headers" ));
37+ try multi .addHandle (try newEasy (& wtr2 . writer , "http://httpbin.org/ip" ));
4038
4139 var keep_running = true ;
4240 while (keep_running ) {
@@ -72,8 +70,8 @@ pub fn main() !void {
7270 // Get the private data (buffer) associated with this handle
7371 var private_data : ? * anyopaque = null ;
7472 try checkCode (c .curl_easy_getinfo (easy_handle , c .CURLINFO_PRIVATE , & private_data ));
75- const writer : * curl.ResizableResponseWriter = @ptrCast (@alignCast (private_data .? ));
73+ const writer : * Writer = @ptrCast (@alignCast (private_data .? ));
7674
77- std .debug .print ("Response body: {s}\n " , .{writer .asSlice ()});
75+ std .debug .print ("Response body: {s}\n " , .{writer .buffered ()});
7876 }
7977}
0 commit comments