Skip to content

Expand OCSP Source interface#772

Merged
lziest merged 4 commits intocloudflare:masterfrom
rolandshoemaker:ocsp-interface-change
May 31, 2017
Merged

Expand OCSP Source interface#772
lziest merged 4 commits intocloudflare:masterfrom
rolandshoemaker:ocsp-interface-change

Conversation

@rolandshoemaker
Copy link
Copy Markdown
Contributor

Changes the ocsp.Source interface from Response(*ocsp.Request) ([]byte, bool) to Response(*ocsp.Request) ([]byte, http.Header, error) so that a source can provide more insight into what has happened when looking for a response than found/not found as well as allowing it to provide specific headers to be set in the subsequent response.

Will add a few more tests + better documentation of the new interface style but wanted to get maintainers thoughts before getting too much deeper.

Fixes #732.

@codecov-io
Copy link
Copy Markdown

codecov-io commented May 23, 2017

Codecov Report

Merging #772 into master will decrease coverage by 0.05%.
The diff coverage is 36.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #772      +/-   ##
==========================================
- Coverage   57.67%   57.62%   -0.06%     
==========================================
  Files          79       76       -3     
  Lines        6965     6942      -23     
==========================================
- Hits         4017     4000      -17     
+ Misses       2521     2519       -2     
+ Partials      427      423       -4
Impacted Files Coverage Δ
ocsp/responder.go 68.75% <36.36%> (-4.48%) ⬇️
signer/local/local.go 66.52% <0%> (-5.79%) ⬇️
transport/roots/system/root.go
transport/roots/system/root_cgo_darwin.go
transport/roots/system/root_darwin.go
helpers/helpers.go 73.74% <0%> (+1.06%) ⬆️
api/client/client.go 60% <0%> (+1.21%) ⬆️
bundler/bundler.go 82.11% <0%> (+1.83%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a7b722b...23f49e1. Read the comment docs.

@lziest
Copy link
Copy Markdown
Contributor

lziest commented May 25, 2017

is this ready?

}
}

func writeExtraHeaders(response http.ResponseWriter, headers http.Header) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels more like overrideHeaders, you intentionally delete original key value and add headers

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

// object and pass it to http.Handle.
type Source interface {
Response(*ocsp.Request) ([]byte, bool)
Response(*ocsp.Request) ([]byte, http.Header, error)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer some docs around why we design this func. It implies that each response will have its own set of header. And in this stub library we actually never use this feature. Can header be specific to one response, or just specific to the entire source.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll write some extra docs here, the main impetus is that we'd like to calculate the cache control period for each response based on the ThisUpdate/NextUpdate fields instead of setting a static cache period over the entire source (as well as set some CDN specific headers on a per-response basis).

Copy link
Copy Markdown
Contributor

@jsha jsha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, except for my one small comment and @lziest's previous comments.

if err != nil {
if err == ErrNotFound {
if extraHeaders != nil {
writeExtraHeaders(response, extraHeaders)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go idiom is to avoid returning meaningful values when an err return is non-nil, so we should probably ignore the extraHeaders on error returns.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@rolandshoemaker
Copy link
Copy Markdown
Contributor Author

Ready for re-review.

@jsha
Copy link
Copy Markdown
Contributor

jsha commented May 31, 2017

LGTM

@lziest
Copy link
Copy Markdown
Contributor

lziest commented May 31, 2017

lgtm

@lziest
Copy link
Copy Markdown
Contributor

lziest commented May 31, 2017

Hoping osx build won't time out this time, I just restarted it.

@rolandshoemaker
Copy link
Copy Markdown
Contributor Author

OS X build still seems unhappy.

@lziest lziest merged commit 9c06c53 into cloudflare:master May 31, 2017
@lziest
Copy link
Copy Markdown
Contributor

lziest commented May 31, 2017

I will deal with it at master branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants