ianmcook commented on code in PR #39081:
URL: https://github.com/apache/arrow/pull/39081#discussion_r1432915275


##########
http/examples/get/client.go:
##########
@@ -0,0 +1,53 @@
+package main
+
+import (
+       "fmt"
+       "net/http"
+       "time"
+
+       "github.com/apache/arrow/go/v15/arrow"
+       "github.com/apache/arrow/go/v15/arrow/ipc"
+       "github.com/apache/arrow/go/v15/arrow/memory"
+)
+
+func main() {
+       start := time.Now()
+       resp, err := http.Get("http://localhost:8000";)
+       if err != nil {
+               panic(err)
+       }
+
+       if resp.StatusCode != http.StatusOK {
+               panic(fmt.Errorf("got non-200 status: %d", resp.StatusCode))
+       }
+       defer resp.Body.Close()
+
+       rdr, err := ipc.NewReader(resp.Body, 
ipc.WithAllocator(memory.DefaultAllocator))
+       if err != nil {
+               panic(err)
+       }
+       defer rdr.Release()
+
+       batches := make([]arrow.Record, 0)
+       defer func() {
+               for _, b := range batches {
+                       b.Release()
+               }
+       }()
+
+       for rdr.Next() {
+               rec := rdr.Record()
+               rec.Retain()
+               batches = append(batches, rec)
+       }
+
+       if rdr.Err() != nil {
+               panic(rdr.Err())
+       }
+
+       execTime := time.Since(start)
+
+       fmt.Println(resp.ContentLength, " bytes recieved")

Review Comment:
   When I use this with the Python example server, it prints `-1 bytes 
received` which means unknown. I believe this is because `resp.ContentLength` 
just gets the `Content-Length` header, which is not set. Is there a way to 
directly get the number of bytes in the response body (without making extra 
copies)?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to