FAQ
Hi,

I need to implement an HTTP client that supports content caching as
specified by RFC 2616.
Could you please give me some directions as to which would be the correct
level in the net/http package where I can do this?
Can I achieve it by extending the http.Client type or would it be better to
create a new type similar to http.Client?

Thanks,
Robert

--

Search Discussions

  • Minux at Dec 13, 2012 at 7:44 pm

    On Thu, Dec 13, 2012 at 11:34 PM, Robert D. wrote:

    I need to implement an HTTP client that supports content caching as
    specified by RFC 2616.
    Could you please give me some directions as to which would be the correct
    level in the net/http package where I can do this?
    Can I achieve it by extending the http.Client type or would it be better
    to create a new type similar to http.Client?
    I think you just need to provide a caching implementation for the
    RoundTripper
    (http://golang.org/pkg/net/http/#RoundTripper) interface.

    --
  • Greg Jones at Dec 17, 2012 at 8:29 pm
    Hi,

    I had some of an implementation and spent some time this weekend tidying it
    up a little bit and I've put it up on Github
    here: https://github.com/gregjones/httpcache

    The cache storage is pluggable and an alternate implementation using, say,
    memcache should be trivial. It comes with an in-memory map version, and
    there's a sub-package for a disk-backed version.
    I've ignored the bits in the RoundTripper docs about not modifying the
    request or interpreting the response - I'm not really sure how to avoid
    doing so.
    It is missing quite a few tests, and hasn't been used in anger, but I hope
    it's a reasonable starting point, if nothing else.

    Comments/suggestions welcome.

    Greg
    On Thursday, 13 December 2012 19:37:17 UTC, minux wrote:


    On Thu, Dec 13, 2012 at 11:34 PM, Robert D. <robert...@gmail.com<javascript:>
    wrote:
    I need to implement an HTTP client that supports content caching as
    specified by RFC 2616.
    Could you please give me some directions as to which would be the correct
    level in the net/http package where I can do this?
    Can I achieve it by extending the http.Client type or would it be better
    to create a new type similar to http.Client?
    I think you just need to provide a caching implementation for the
    RoundTripper
    (http://golang.org/pkg/net/http/#RoundTripper) interface.
    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 13, '12 at 3:34p
activeDec 17, '12 at 8:29p
posts3
users3
websitegolang.org

3 users in discussion

Greg Jones: 1 post Minux: 1 post Robert D.: 1 post

People

Translate

site design / logo © 2022 Grokbase