gnarroway / hato

An HTTP client for Clojure, wrapping JDK 11's HttpClient
MIT License
380 stars 27 forks source link

`last?` - documentation #58

Open vemv opened 1 year ago

vemv commented 1 year ago

Hi there,

thank you for the excellent library.

There doesn't appear to be documentation as for what last? means.

Cheers - V

sg-qwt commented 1 year ago

I accidentally discovered the meaning of last? by receiving a very large payload from some ws stream the other day.

If the payload is really large, the msg will be splitted in multi parts, with the first (n-1) parts of msg coming with last?=false, and the last msg with last?=true:

for example, I may receive 3 on-messages in a roll for a really huge json payload, and I need to concat them myself to get the complete json payload.

  1. msg: "[{xxxxxxxxxxxxxxxxxxx," last?: false
  2. msg: "xxxxxxxxxx", last?:false
  3. msg: "xxxxxxx}]", last?:true

There seems some docs in jdk docs regarding that. https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/WebSocket.html

Although I'm not sure the splitting behavior is controlled by server side or client side. Is there way to control the threshold size of whether to splitting msg into parts?