Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 10eb476

Browse files
committed
Remove unsed, add fork info, run gomod init etc.
1 parent 901d907 commit 10eb476

File tree

19 files changed

+70
-497
lines changed

19 files changed

+70
-497
lines changed

‎.github/workflows/test.yml‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
on:
2+
push:
3+
branches: [master]
4+
pull_request:
5+
name: Test
6+
permissions:
7+
contents: read
8+
jobs:
9+
test:
10+
strategy:
11+
matrix:
12+
go-version: [1.21.x, 1.22.x]
13+
platform: [ubuntu-latest, macos-latest, windows-latest]
14+
runs-on: ${{ matrix.platform }}
15+
steps:
16+
- name: Install Go
17+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
18+
with:
19+
go-version: ${{ matrix.go-version }}
20+
- name: Install staticcheck
21+
run: go install honnef.co/go/tools/cmd/staticcheck@latest
22+
shell: bash
23+
- name: Update PATH
24+
run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
25+
shell: bash
26+
- name: Checkout code
27+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
28+
- name: Fmt
29+
if: matrix.platform != 'windows-latest'
30+
run: "diff <(gofmt -d .) <(printf '')"
31+
shell: bash
32+
- name: Vet
33+
run: go vet ./...
34+
- name: Staticcheck
35+
# Ubuntu latest go.
36+
if: strategy.job-index == 3
37+
run: staticcheck ./...
38+
- name: Test
39+
run: go test -race ./... -coverpkg=./...

‎.travis.yml‎

Lines changed: 0 additions & 18 deletions
This file was deleted.

‎LICENSE.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Copyright �� 2012 Greg Jones (greg.jones@gmail.com)
1+
Original work Copyright © 2012 Greg Jones (greg.jones@gmail.com)
2+
Modified work Copyright © 2024 The Hugo Authors.
23

34
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
45

‎README.md‎

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,8 @@
1-
httpcache
2-
=========
1+
[![Tests on Linux, MacOS and Windows](https://github.com/gohugoio/httpcache/workflows/Test/badge.svg)](https://github.com/gohugoio/httpcache/actions?query=workflow:Test)
2+
[![Go Report Card](https://goreportcard.com/badge/github.com/gohugoio/httpcache)](https://goreportcard.com/report/github.com/gohugoio/httpcache)
3+
[![GoDoc](https://godoc.org/github.com/gohugoio/httpcache?status.svg)](https://godoc.org/github.com/gohugoio/httpcache)
34

4-
[![Build Status](https://travis-ci.org/gregjones/httpcache.svg?branch=master)](https://travis-ci.org/gregjones/httpcache) [![GoDoc](https://godoc.org/github.com/gregjones/httpcache?status.svg)](https://godoc.org/github.com/gregjones/httpcache)
5-
6-
Package httpcache provides a http.RoundTripper implementation that works as a mostly [RFC 7234](https://tools.ietf.org/html/rfc7234) compliant cache for http responses.
7-
8-
It is only suitable for use as a 'private' cache (i.e. for a web-browser or an API-client and not for a shared proxy).
9-
10-
This project isn't actively maintained; it works for what I, and seemingly others, want to do with it, and I consider it "done". That said, if you find any issues, please open a Pull Request and I will try to review it. Any changes now that change the public API won't be considered.
11-
12-
Cache Backends
13-
--------------
14-
15-
- The built-in 'memory' cache stores responses in an in-memory map.
16-
- [`github.com/gregjones/httpcache/diskcache`](https://github.com/gregjones/httpcache/tree/master/diskcache) provides a filesystem-backed cache using the [diskv](https://github.com/peterbourgon/diskv) library.
17-
- [`github.com/gregjones/httpcache/memcache`](https://github.com/gregjones/httpcache/tree/master/memcache) provides memcache implementations, for both App Engine and 'normal' memcache servers.
18-
- [`sourcegraph.com/sourcegraph/s3cache`](https://sourcegraph.com/github.com/sourcegraph/s3cache) uses Amazon S3 for storage.
19-
- [`github.com/gregjones/httpcache/leveldbcache`](https://github.com/gregjones/httpcache/tree/master/leveldbcache) provides a filesystem-backed cache using [leveldb](https://github.com/syndtr/goleveldb/leveldb).
20-
- [`github.com/die-net/lrucache`](https://github.com/die-net/lrucache) provides an in-memory cache that will evict least-recently used entries.
21-
- [`github.com/die-net/lrucache/twotier`](https://github.com/die-net/lrucache/tree/master/twotier) allows caches to be combined, for example to use lrucache above with a persistent disk-cache.
22-
- [`github.com/birkelund/boltdbcache`](https://github.com/birkelund/boltdbcache) provides a BoltDB implementation (based on the [bbolt](https://github.com/coreos/bbolt) fork).
23-
24-
If you implement any other backend and wish it to be linked here, please send a PR editing this file.
5+
This is a fork of [gregjones/httpcache](https://github.com/gregjones/httpcache).
256

267
License
278
-------

‎diskcache/diskcache.go‎

Lines changed: 0 additions & 61 deletions
This file was deleted.

‎diskcache/diskcache_test.go‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎go.mod‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/gohugoio/httpcache
2+
3+
go 1.22.2

‎httpcache.go‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
//
44
// It is only suitable for use as a 'private' cache (i.e. for a web-browser or an API-client
55
// and not for a shared proxy).
6-
//
76
package httpcache
87

98
import (
109
"bufio"
1110
"bytes"
1211
"errors"
1312
"io"
14-
"io/ioutil"
1513
"net/http"
1614
"net/http/httputil"
1715
"strings"
@@ -234,7 +232,7 @@ func (t *Transport) RoundTrip(req *http.Request) (resp *http.Response, err error
234232
R: resp.Body,
235233
OnEOF: func(r io.Reader) {
236234
resp := *resp
237-
resp.Body = ioutil.NopCloser(r)
235+
resp.Body = io.NopCloser(r)
238236
respBytes, err := httputil.DumpResponse(&resp, true)
239237
if err == nil {
240238
t.Cache.Set(cacheKey, respBytes)
@@ -287,7 +285,7 @@ var clock timer = &realClock{}
287285
// transparent indicates the response should not be used to fulfil the request
288286
//
289287
// Because this is only a private cache, 'public' and 'private' in cache-control aren't
290-
// signficant. Similarly, smax-age isn't used.
288+
// significant. Similarly, smax-age isn't used.
291289
func getFreshness(respHeaders, reqHeaders http.Header) (freshness int) {
292290
respCacheControl := parseCacheControl(respHeaders)
293291
reqCacheControl := parseCacheControl(reqHeaders)

0 commit comments

Comments
 (0)