FAQ
I've noticed that rpc/client allows connecting over HTTP, but only using
gob encoding. And that jsonrpc/client allows json encoding but only over
raw socket connections.

I'm working on a patch that would add DialHTTPPath to jsonrpc/client.go, it
would allow jsonrpc over HTTP, the diff is at [1].

The diff is incomplete - the http connect string needs to be parsed
correctly, and I want to try it with some Perl/Python jsonrpc servers.
But I'd be interested in comments ie am I approaching the change in the
correct manner?

[1]
http://code.google.com/r/soniasnowfrog-shiny-octo/source/detail?r=1de8c97b51817f3624a8f7b96972066afffcb63b


--

Search Discussions

  • Sonia Hamilton at Oct 8, 2012 at 6:41 am
    I've been reading through the library code for net/rpc, and noticed
    that DialHTTPPath in net/rpc/client.go requires the responding server to
    respond to a CONNECT first:

    io.WriteString(conn, "CONNECT "+path+" HTTP/1.0\n\n")

    // Require successful HTTP response
    // before switching to RPC protocol.
    resp, err := http.ReadResponse(bufio.NewReader(conn),
    &http.Request{Method: "CONNECT"})
    if err == nil && resp.Status == connected {
    return NewClient(conn), nil
    }
    if err == nil {
    err = errors.New("unexpected HTTP response: " + resp.Status)
    }

    Reading through the RFC [1] for HTTP it says this about CONNECT:

    CONNECT

    This specification reserves the method name CONNECT for use with a proxy
    that can dynamically switch to being a tunnel (e.g. SSL tunneling[44]<http://www.w3.org/Protocols/rfc2616/rfc2616-sec17.html#bib44>
    ).

    So why would the rpc client be using a CONNECT for http? Just a hack to
    make life easier for Go? I've noticed other JSON-RPC libraries reject the
    CONNECT, only allowing a straight POST.

    [1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

    On Monday, 8 October 2012 01:03:08 UTC+11, Sonia Hamilton wrote:

    I've noticed that rpc/client allows connecting over HTTP, but only using
    gob encoding. And that jsonrpc/client allows json encoding but only over
    raw socket connections.

    I'm working on a patch that would add DialHTTPPath to jsonrpc/client.go,
    it would allow jsonrpc over HTTP, the diff is at [1].

    The diff is incomplete - the http connect string needs to be parsed
    correctly, and I want to try it with some Perl/Python jsonrpc servers.
    But I'd be interested in comments ie am I approaching the change in the
    correct manner?

    [1]
    http://code.google.com/r/soniasnowfrog-shiny-octo/source/detail?r=1de8c97b51817f3624a8f7b96972066afffcb63b

    --
  • Russ Cox at Oct 9, 2012 at 4:54 pm

    On Mon, Oct 8, 2012 at 2:35 AM, Sonia Hamilton wrote:
    Reading through the RFC [1] for HTTP it says this about CONNECT:

    CONNECT

    This specification reserves the method name CONNECT for use with a proxy
    that can dynamically switch to being a tunnel (e.g. SSL tunneling[44]).

    So why would the rpc client be using a CONNECT for http? Just a hack to make
    life easier for Go? I've noticed other JSON-RPC libraries reject the
    CONNECT, only allowing a straight POST.
    The client is using a CONNECT to begin speaking the RPC protocol,
    which is not HTTP, just tunneled over it via the CONNECT.

    There is no full definition of what "JSON-RPC" means as far as the
    outer framing protocol. You probably need to write a custom codec to
    get the specific HTTP transport you are looking for.

    If your server is expecting a straight POST, that might just not be
    JSON-RPC. It might be easiest to do a JSON marshal and a JSON
    unmarshal yourself, around an ordinary HTTP POST.

    Russ

    --
  • Sonia Hamilton at Oct 10, 2012 at 1:38 am
    Thanks Russ, that's what I'm writing - using the existing Go RPC framework,
    with json encoding in the Go http/client functionality.
    https://github.com/soniah/deltoro

    A good learning exercise :-)

    Sonia.
    On Wednesday, 10 October 2012 01:20:39 UTC+11, Russ Cox wrote:
    On Mon, Oct 8, 2012 at 2:35 AM, Sonia Hamilton wrote:
    Reading through the RFC [1] for HTTP it says this about CONNECT:

    CONNECT

    This specification reserves the method name CONNECT for use with a proxy
    that can dynamically switch to being a tunnel (e.g. SSL tunneling[44]).

    So why would the rpc client be using a CONNECT for http? Just a hack to make
    life easier for Go? I've noticed other JSON-RPC libraries reject the
    CONNECT, only allowing a straight POST.
    The client is using a CONNECT to begin speaking the RPC protocol,
    which is not HTTP, just tunneled over it via the CONNECT.

    There is no full definition of what "JSON-RPC" means as far as the
    outer framing protocol. You probably need to write a custom codec to
    get the specific HTTP transport you are looking for.

    If your server is expecting a straight POST, that might just not be
    JSON-RPC. It might be easiest to do a JSON marshal and a JSON
    unmarshal yourself, around an ordinary HTTP POST.

    Russ
    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 7, '12 at 2:03p
activeOct 10, '12 at 1:38a
posts4
users2
websitegolang.org

2 users in discussion

Sonia Hamilton: 3 posts Russ Cox: 1 post

People

Translate

site design / logo © 2021 Grokbase