jsr369-experts@servlet-spec.java.net

[jsr369-experts] Re: [servlet-spec users] PushBuilder with conditional headers

From: Greg Wilkins <gregw_at_webtide.com>
Date: Thu, 9 Mar 2017 10:16:16 +0900

Shing,

I think it would make sense to have

pushBuilder.setHeader(“If-None-Match”, value)

be identical to:

pushBuilder.ifNoneMatch(value)


and for

pushBuilder.addHeader(“If-None-Match”, value)

be identical to:

String prev = pushBuilder.getHeader(“If-None-Match”);
pushBuilder.ifNoneMatch(prev==null?value:(prev+", "+value);



regards



On 7 March 2017 at 08:50, Shing Wai Chan <shing.wai.chan_at_oracle.com> wrote:

> This email continues the previous discussion [1] of conditional headers
> mentioned in RFC 2732, but not in PushBuilder.
>
> In PushBuilder, we have add/set header through
> #addHeader(String name, String value)
> #setHeader(String name, String value)
>
> Also, we have the following
> i) #eTag(String eTag), #lastModified(String lastModified)
> (Per previous discussion in EG, we will rename them as
> #ifNoneMatch(String), #ifModifiedSince(String). We will use the old name in
> the following discussion.)
> ii) #conditional(boolean)
> So if #eTag is invoked with #conditional(false), then the eTag header will
> not be added.
>
> Suppose we want to add the conditional header:
> If-None-Match: ”xyzzy”
> Then we can do the following (A):
> pushBuilder.eTag(“xyzzy”); (A1)
> pushBuilder.conditional(true); (A2)
>
> What is the behavior of invoking (B):
> pushBuilder.add(“If-None-Match”, “xyzzy”)
>
> a) (B) = (A1)
> But this means that #addHeader will not actually add a conditional
> header.
> b) (B) = (A1) + (A2)
> This is problematic here because (A2) is for all conditional headers, not
> just “If-None-Match”.
> c) (B) = adding If-None-Match: “xyzzy” independently of #conditional
> This means #conditional(false) will not take effect for those conditional
> header adding through #addHeader.
> d) (B) is illegal, which will throw IllegalArgumentException for any
> conditional headers.
> If we go this way, then we need to add API for the other three
> conditional headers.
>
> All the above are not quite satisfactory.
>
> Do we still want to keep #eTag, #lastModified, #conditional et al API for
> conditional headers?
>
> Any comment?
>
> Shing Wai Chan
>
> ps.
> [1] https://java.net/projects/servlet-spec/lists/jsr369-
> experts/archive/2017-03/message/3
>



-- 
Greg Wilkins <gregw@webtide.com> CTO http://webtide.com