(ctx context.Context, request []byte)
| 183 | } |
| 184 | |
| 185 | func (h *Host) callHostHTTPStreamRead(ctx context.Context, request []byte) ([]byte, error) { |
| 186 | var req rpcHostHTTPStreamReadRequest |
| 187 | if errUnmarshal := json.Unmarshal(request, &req); errUnmarshal != nil { |
| 188 | return nil, fmt.Errorf("decode host http stream read request: %w", errUnmarshal) |
| 189 | } |
| 190 | if h == nil || h.httpStreams == nil { |
| 191 | return nil, fmt.Errorf("host http stream bridge is unavailable") |
| 192 | } |
| 193 | chunk, done, errRead := h.httpStreams.read(ctx, req.StreamID) |
| 194 | if errRead != nil { |
| 195 | return nil, errRead |
| 196 | } |
| 197 | resp := rpcHostHTTPStreamReadResponse{ |
| 198 | Payload: append([]byte(nil), chunk.Payload...), |
| 199 | Done: done, |
| 200 | } |
| 201 | if chunk.Err != nil { |
| 202 | resp.Error = chunk.Err.Error() |
| 203 | resp.Done = true |
| 204 | } |
| 205 | return marshalRPCResult(resp) |
| 206 | } |
| 207 | |
| 208 | func (h *Host) callHostHTTPStreamClose(request []byte) ([]byte, error) { |
| 209 | var req rpcHostHTTPStreamCloseRequest |
no test coverage detected