Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It seems it miss the Content-Length field #14

Closed
chinajuanbob opened this issue Jun 21, 2020 · 5 comments · Fixed by #15
Closed

It seems it miss the Content-Length field #14

chinajuanbob opened this issue Jun 21, 2020 · 5 comments · Fixed by #15
Labels
bug Something isn't working

Comments

@chinajuanbob
Copy link

config

:2020 {
    reverse_proxy {
        to localhost:2021
    }
    http_cache {
        cache_type in_memory 
        match_path /
    }
}

output

$ curl -I localhost:2020/libtaos.so.1
HTTP/1.1 200 OK
Accept-Ranges: bytes
Date: Sun, 21 Jun 2020 13:45:02 GMT
Etag: "qa5jk3198eg"
Last-Modified: Mon, 11 May 2020 05:36:03 GMT
Server: Caddy
X-Cache-Status: hit

$ curl -I localhost:2021/libtaos.so.1
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 2110408  <----------- here
Etag: "qa5jk3198eg"
Last-Modified: Mon, 11 May 2020 05:36:03 GMT
Server: Caddy
Date: Sun, 21 Jun 2020 13:45:28 GMT
@sillygod sillygod added the bug Something isn't working label Jun 22, 2020
@sillygod
Copy link
Owner

Thanks for filling this issue. Currently, I mean to delete the content-length field to avoid a certain situation to working with the distributed cache.

I will find out a solution to make it return with the content-length field. BTW, may I know what error you encountered when the content-length was not returned.

@sillygod
Copy link
Owner

sillygod commented Jun 22, 2020

Hi @chinajuanbob,

I've made a fix for this issue. Would you like to test it? the latest release Is 0.3.3

@chinajuanbob
Copy link
Author

Thanks for the quick update.

There is the Content-Length, however, I hit this stack print, and I'm not sure it is a bug or expected. In my opinion, a print error is enough.

{"level":"error","ts":1592821617.1456428,"logger":"http.handlers.http_cache","msg":"cache handler","error":"no precollect content"}
goroutine 311 [running]:
runtime/debug.Stack(0x212d112, 0x0, 0x0)
        /usr/local/go/src/runtime/debug/stack.go:24 +0xab
runtime/debug.PrintStack()
        /usr/local/go/src/runtime/debug/stack.go:16 +0x34
github.com/sillygod/cdp-cache.(*Handler).ServeHTTP(0xc0006a3040, 0x7f0c4591de50, 0xc0008a00a0, 0xc0004c9700, 0x3c2e920, 0xc00095a360, 0x0, 0x0)
        /go/pkg/mod/github.com/sillygod/[email protected]/handler.go:328 +0x6f2
github.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1(0x7f0c4591de50, 0xc0008a00a0, 0xc0004c9700, 0xc00095a930, 0x3c2f8e0)
        /go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/routes.go:256 +0x7b
github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0xc00095a390, 0x7f0c4591de50, 0xc0008a00a0, 0xc0004c9700, 0x0, 0x0)
        /go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/caddyhttp.go:58 +0x52
github.com/hairyhenderson/caddyprom.Metrics.ServeHTTP.func1(0x7f0c4591de50, 0xc0008a00a0, 0xc0004c9700)
        /go/pkg/mod/github.com/hairyhenderson/[email protected]/caddyprom.go:95 +0x72
net/http.HandlerFunc.ServeHTTP(0xc000520120, 0x7f0c4591de50, 0xc0008a00a0, 0xc0004c9700)
        /usr/local/go/src/net/http/server.go:2012 +0x52
github.com/prometheus/client_golang/prometheus/promhttp.InstrumentHandlerResponseSize.func1(0x7f0c4591de50, 0xc0008a0050, 0xc0004c9700)
        /go/pkg/mod/github.com/prometheus/[email protected]/prometheus/promhttp/instrument_server.go:196 +0x105
net/http.HandlerFunc.ServeHTTP(0xc00095a5a0, 0x7f0c4591de50, 0xc0008a0050, 0xc0004c9700)
        /usr/local/go/src/net/http/server.go:2012 +0x52
github.com/prometheus/client_golang/prometheus/promhttp.InstrumentHandlerDuration.func1(0x7f0c4591de50, 0xc0008a0000, 0xc0004c9700)
        /go/pkg/mod/github.com/prometheus/[email protected]/prometheus/promhttp/instrument_server.go:68 +0x13d
net/http.HandlerFunc.ServeHTTP(0xc00095a750, 0x7f0c4591de50, 0xc0008a0000, 0xc0004c9700)
        /usr/local/go/src/net/http/server.go:2012 +0x52
github.com/prometheus/client_golang/prometheus/promhttp.InstrumentHandlerCounter.func1(0x3c4e040, 0xc0006f6380, 0xc0004c9700)
        /go/pkg/mod/github.com/prometheus/[email protected]/prometheus/promhttp/instrument_server.go:100 +0xf9
net/http.HandlerFunc.ServeHTTP(...)
      ...

@sillygod
Copy link
Owner

@chinajuanbob Yes, that's expected! I mean to do a trackback print here. In the future release, when this project is more concrete, I will make this to only print an error log with the stack.

Maybe, you can open another issue labeled as an enhancement to simply this error log.

@chinajuanbob
Copy link
Author

#16 is opened to track the error log issue, however, it seems I don't have the right to add labels to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants