|
Cro: libraries and tools for building reactive services in Perl 6 | cro.services/ | Logs: irclog.perlgeek.de/cro/ Set by moderator on 14 February 2018. |
|||
|
02:59
ilbot3 joined
|
|||
| moderator | Cro: libraries and tools for building reactive services in Perl 6 | cro.services/ | Logs: irclog.perlgeek.de/cro/ | ||
|
13:06
daviddavis_ joined
|
|||
| daviddavis_ | Is it possible to decode the Cro::WebSocket::Message::close message? I've tried after using body-blob.result but catch an error stating malformed termination of utf-8 string. | 15:11 | |
| jnthn | The error comes from body-blob.result? | 15:14 | |
| Or when you try to decode that? | |||
| daviddavis_ | When I try to decode that. It looks something like this | 15:17 | |
| pastebin.com/gYR5QEgb | |||
| I know the type is a blob and when I add a catch. I get an error saying "Malformed termination of UTF-8 string" | 15:18 | ||
| jnthn | What if you .perl the thing coming back? | 15:22 | |
| From the RFC: | 15:23 | ||
| If there is a body, the first two bytes of the body MUST be a 2-byte unsigned integer (in network byte order) representing a status code with value /code/ defined in Section 7.4. Following the 2-byte integer, the body MAY contain UTF-8-encoded data | |||
| So provided we're just passing along the body as a whole thing, then any UTF-8 would be *after* the 2-byte integer, so a .subbuf(2) would be required on the body-blob | 15:25 | ||
| daviddavis_ | Do you mean if I do $value.perl? I got "Blob.new(3,233)" | 15:33 | |
| timotimo | so there's only the status code integer, no actual text? | 15:38 | |
| jnthn | Looks like, yes | 15:44 | |
| daviddavis_ | Yes I just realised. I readded the close message and I can see it now | ||
| jnthn | Arguably we should try and split that integer code out for you | ||
| daviddavis_ | with the text it is. Blob.new(3,232,97,100,105,111,115,44,32,97,109,105,103,111,33) | 15:45 | |
| I should be able to get the code with this right? | 15:46 | ||
| github.com/croservices/cro-websock...dler.t#L51 | |||
| jnthn | Yes | 15:47 | |
| daviddavis_ | And it did, thanks a lot! I had some real head scratching moments with this originally. I've never had to do a lot of work with decoding blobs. | 15:52 | |
| jnthn | Yeah, I suspect you won't be the only person who trips over this, which means we should probably consider a subtype of Message that comes with a .code property, and then .body-blob has that stripped away | 15:56 | |
| daviddavis_ | Most likely, I mainly spent time looking around to see if any of Cro handled close messages and codes. | 16:32 | |
| timotimo | maybe we should have suggested utf8-c8 which would at least have shown there's "garbage" at the beginning | 16:41 | |
| rather than just throw an exception | |||
|
17:42
lizmat joined
18:23
lizmat joined
22:09
brrt joined
22:24
lizmat joined
|
|||