srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/internal/ipc/ipc.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/ipc/ipc.go')
-rw-r--r--internal/ipc/ipc.go28
1 files changed, 25 insertions, 3 deletions
diff --git a/internal/ipc/ipc.go b/internal/ipc/ipc.go
index c9d92b4..b1a997a 100644
--- a/internal/ipc/ipc.go
+++ b/internal/ipc/ipc.go
@@ -15,17 +15,22 @@ import (
// Request is sent by a client to the daemon.
type Request struct {
- Type string `json:"type"` // "list", "get", or "subscribe"
+ Type string `json:"type"` // "list", "get", "subscribe", or "repeat"
Limit int `json:"limit,omitempty"`
BeforeID int64 `json:"before_id,omitempty"`
ID int64 `json:"id,omitempty"`
+
+ // For "repeat": send Raw to scheme://host exactly as given.
+ Scheme string `json:"scheme,omitempty"`
+ Host string `json:"host,omitempty"`
+ Raw []byte `json:"raw,omitempty"`
}
// Response is sent by the daemon to a client.
type Response struct {
- Type string `json:"type"` // "list", "get", "new", or "error"
+ Type string `json:"type"` // "list", "get", "new", "repeat", or "error"
Entries []store.Summary `json:"entries,omitempty"` // for "list"
- Detail *EntryDetail `json:"detail,omitempty"` // for "get"
+ Detail *EntryDetail `json:"detail,omitempty"` // for "get" and "repeat"
New *store.Summary `json:"new,omitempty"` // for "new" (subscribe push)
Error string `json:"error,omitempty"`
}
@@ -92,6 +97,23 @@ func (c *Client) Get(id int64) (*EntryDetail, error) {
return resp.Detail, nil
}
+// Repeat sends raw to scheme://host exactly as given (no re-serialization,
+// no header injection) and returns the resulting entry, including the raw
+// response bytes. The exchange is also recorded to history.
+func (c *Client) Repeat(scheme, host string, raw []byte) (*EntryDetail, error) {
+ if err := c.enc.Encode(Request{Type: "repeat", Scheme: scheme, Host: host, Raw: raw}); err != nil {
+ return nil, err
+ }
+ var resp Response
+ if err := c.dec.Decode(&resp); err != nil {
+ return nil, err
+ }
+ if resp.Type == "error" {
+ return nil, errors.New(resp.Error)
+ }
+ return resp.Detail, nil
+}
+
// Subscribe opens a dedicated connection that streams newly captured
// history entries as they happen. The returned channel is closed when
// the connection ends; call the returned close func to stop early.