All,

I got puzzled by how to read a response size > 32KBytes from http 
resp.Body. All I get is 32768 bytes. With either io.Read functions or 
bufio.Reader.


















*buffer := make([]byte, 1024)var total_bytes_read int for {  len, err := 
io.ReadAtLeast(res.Body, buffer, 1024)  total_bytes_read += len  
log.Println(len, "bytes recevied, total received bytes: ", 
total_bytes_read)  if err != nil {    if err == io.EOF {      
log.Println("EOF: last chunk received")    } else {      log.Println(err)  
  }    break  }   time.Sleep(1 * time.Second)}   log.Println("Total bytes 
received:", total_bytes_read)err = res.Body.Close()*

What I see is: 

*{"level":"info","msg":"1024 bytes recevied, total received bytes: 
1024","time":"2022-06-19T19:47:48-05:00"} *
*{"level":"info","msg":"1024 bytes recevied, total received bytes: 
2048","time":"2022-06-19T19:47:49-05:00"} *

*{"level":"info","msg":"1024 bytes recevied, total received bytes: 
3072","time":"2022-06-19T19:47:50-05:00"}*
*...*
*{"level":"info","msg":"1024 bytes recevied, total received bytes: 
30720","time":"2022-06-19T19:48:17-05:00"}*
*{"level":"info","msg":"1024 bytes recevied, total received bytes: 
31744","time":"2022-06-19T19:48:18-05:00"} *
*{"level":"info","msg":"1024 bytes recevied, total received bytes: 
32768","time":"2022-06-19T19:48:19-05:00"}*

Then it got stuck and waiting for return from the io.Read. Not sure if what 
I did is correct. Got the same observation when using more popular 
bufio.Read as well.

Thanks!
-Min

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/bdccdcf0-8b8f-4c4c-b13b-2c75f24d6092n%40googlegroups.com.

Reply via email to