Hello!

I am using channels to talk to an HTTP server running on localhost:

    let channel = ch_open('localhost:1234', {'mode': 'raw'}
    let str = '...'    " <- this is raw HTTP
    let response = ch_evalraw(channel, str)

The HTTP response's body is a JSON string.

I find intermittently (say 50%-70% of the time) the JSON in the response is 
truncated.  It is alway truncated in the same spot, which is after ~4300 bytes.

The weird thing is that when I log channel activity with `call 
ch_logfile('channelog', 'w')` the response is never truncated.

In the channel log I can see the successful response being received in two 
parts, with the first part corresponding to what I get "in full" when the 
response is truncated.  Here's an excerpt:

 2.284366 on 8: Created channel
 2.285209 on 8: Connecting to localhost port 1234
 2.285309 on 8: Waiting for connection (waiting 1 msec)...
 2.285449 on 8: Connection made
 2.285731 SEND on 8: 'POST /path/to/endpoint HTTP/1.0
 Host: localhost
 Content-Type: application/x-www-form-urlencoded
 Content-Length: 120
 
 {"some json that":"i am sending"}'
2.285779 on 8: Blocking RAW read, timeout: 2000 msec
2.285793 on 8: Waiting for up to 2000 msec
2.286701 RECV on 8: 'HTTP/1.0 200 OK^M
Content-Type: application/json^M
Date: Wed, 25 Oct 2017 11:02:55 GMT^M
^M
{"first part of response":"json truncated here
2.286753 RECV on 8: 'and it continues on to the end}'
2.286775 on 8: Returning 6320 bytes
2.287753 on 8: channel_select_check(): Read EOF from ch_part[0], closing
2.291400 : looking for messages on channels
2.291412 on 8: Closing channel because all readable fds are closed
2.291420 on 8: Closing channel
2.291427 on 8: Closing channel
2.291433 on 8: Clearing channel
2.291441 on 8: Freeing channel

It seems that channel logging somehow forces `ch_evalraw()` to stitch together 
all received parts into a single response.  And that without channel logging, 
50%-70% of the time only the part received first is returned by `ch_evalraw()`.

How can I get `ch_evalraw()` to give me everything it receives without having 
to log the channel's activity?

Many thanks in advance!

Yours,
Andrew Stewart

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui