good morning!!!!

Skip to content
Snippets Groups Projects
Verified Commit d5c5714c authored by a's avatar a
Browse files

fuck me

parent 00d78f82
Branches
Tags
1 merge request!23Whatthefuck
Pipeline #30099 failed
...@@ -59,7 +59,9 @@ func Dial(ctx context.Context, client *http.Client, target string) (*Client, err ...@@ -59,7 +59,9 @@ func Dial(ctx context.Context, client *http.Client, target string) (*Client, err
if client == nil { if client == nil {
client = http.DefaultClient client = http.DefaultClient
} }
return &Client{remote: target, c: client, headers: http.Header{}}, nil return &Client{remote: target, c: client, headers: http.Header{
"Content-Type": []string{"application/json"},
}}, nil
} }
func (c *Client) SetHeader(key string, value string) { func (c *Client) SetHeader(key string, value string) {
...@@ -196,6 +198,5 @@ func (c *Client) postBuf(ctx context.Context, rd io.Reader) (*http.Response, err ...@@ -196,6 +198,5 @@ func (c *Client) postBuf(ctx context.Context, rd io.Reader) (*http.Response, err
} }
} }
}() }()
hreq.Header.Add("Content-Type", "application/json")
return c.c.Do(hreq) return c.c.Do(hreq)
} }
...@@ -11,6 +11,7 @@ import ( ...@@ -11,6 +11,7 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"strings" "strings"
"sync"
"gfx.cafe/open/jrpc/pkg/codec" "gfx.cafe/open/jrpc/pkg/codec"
"gfx.cafe/open/jrpc/pkg/serverutil" "gfx.cafe/open/jrpc/pkg/serverutil"
...@@ -29,6 +30,8 @@ type Codec struct { ...@@ -29,6 +30,8 @@ type Codec struct {
msgs chan *serverutil.Bundle msgs chan *serverutil.Bundle
errCh chan httpError errCh chan httpError
mu sync.Mutex
i codec.PeerInfo i codec.PeerInfo
} }
......
...@@ -65,6 +65,11 @@ func (c *callRespWriter) Send(v any, e error) (err error) { ...@@ -65,6 +65,11 @@ func (c *callRespWriter) Send(v any, e error) (err error) {
if err != nil { if err != nil {
return err return err
} }
select {
case <-c.ctx.Done():
return c.ctx.Err()
default:
}
defer c.cr.mu.Release(1) defer c.cr.mu.Release(1)
if c.err != nil { if c.err != nil {
e = c.err e = c.err
...@@ -77,7 +82,6 @@ func (c *callRespWriter) Send(v any, e error) (err error) { ...@@ -77,7 +82,6 @@ func (c *callRespWriter) Send(v any, e error) (err error) {
if v != nil { if v != nil {
ce.v = &v ce.v = &v
} }
err = c.cr.send(c.ctx, ce) err = c.cr.send(c.ctx, ce)
if err != nil { if err != nil {
return err return err
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment