You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mi...@apache.org on 2019/10/11 08:30:22 UTC

[tomcat] branch BZ-63835/8.5.x created (now 6ff2233)

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch BZ-63835/8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git.


      at 6ff2233  First draft

This branch includes the following new commits:

     new 6ff2233  First draft

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] branch BZ-63835/8.5.x created (now 6ff2233)

Posted by Michael Osipov <mi...@apache.org>.
Am 2019-10-11 um 15:20 schrieb Mark Thomas:
> On 11/10/2019 14:10, Rémy Maucherat wrote:
>> On Fri, Oct 11, 2019 at 1:51 PM Michael Osipov <michaelo@apache.org
>> <ma...@apache.org>> wrote:
>>
>>      Am 2019-10-11 um 11:32 schrieb Rémy Maucherat:
>>      > On Fri, Oct 11, 2019 at 10:43 AM Mark Thomas <markt@apache.org
>>      <ma...@apache.org>> wrote:
>>      >
>>      >> On 11/10/2019 09:30, michaelo@apache.org
>>      <ma...@apache.org> wrote:
>>      >>> This is an automated email from the ASF dual-hosted git repository.
>>      >>>
>>      >>> michaelo pushed a change to branch BZ-63835/8.5.x
>>      >>
>>      >> New features should be implemented against master and then
>>      back-ported
>>      >> (assuming the community accepts them).
>>      >>
>>      >
>>      > I also (still) prefer either PRs (it allows comments) or in master.
>>
>>      This is a first draft, nothing PR worthy. As soon as I see the code
>>      working, I will create the PR by then and when approved in general I
>>      will add tests and re-request review. So please be patient.
>>
>>
>> For this use I'd recommend using your own forked repository then. Using
>> a branch for that doesn't work for me, it sends way too many emails that
>> are not actually useful to dev to the dev mailing list. I tried for a
>> while, it didn't work, sorry :(
> 
> I use upstream so much I should probably reconfigure the names of the
> remotes in my checkout:
> origin -> fork
> upstream -> origin

This doesn't feel right. Origin always denotes the repo you cloned from, 
your fork. So keeping origin and upstream seems fine. I call upstream 
simply 'apache' in my forked ones and point to gitbox.apache.org.

Michael


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] branch BZ-63835/8.5.x created (now 6ff2233)

Posted by Mark Thomas <ma...@apache.org>.
On 11/10/2019 14:10, Rémy Maucherat wrote:
> On Fri, Oct 11, 2019 at 1:51 PM Michael Osipov <michaelo@apache.org
> <ma...@apache.org>> wrote:
> 
>     Am 2019-10-11 um 11:32 schrieb Rémy Maucherat:
>     > On Fri, Oct 11, 2019 at 10:43 AM Mark Thomas <markt@apache.org
>     <ma...@apache.org>> wrote:
>     >
>     >> On 11/10/2019 09:30, michaelo@apache.org
>     <ma...@apache.org> wrote:
>     >>> This is an automated email from the ASF dual-hosted git repository.
>     >>>
>     >>> michaelo pushed a change to branch BZ-63835/8.5.x
>     >>
>     >> New features should be implemented against master and then
>     back-ported
>     >> (assuming the community accepts them).
>     >>
>     >
>     > I also (still) prefer either PRs (it allows comments) or in master.
> 
>     This is a first draft, nothing PR worthy. As soon as I see the code
>     working, I will create the PR by then and when approved in general I
>     will add tests and re-request review. So please be patient.
> 
> 
> For this use I'd recommend using your own forked repository then. Using
> a branch for that doesn't work for me, it sends way too many emails that
> are not actually useful to dev to the dev mailing list. I tried for a
> while, it didn't work, sorry :(
> 
> So either:
> - a PR
> - directly in master

master is fine when you are fairly sure the code is right. It isn't the
place for experiments since we release 9.0.x off master.

> - your git fork

I use the fork approach.

I have a local checkout of my fork with the apache/tomcat github mirror
configured as an additional remote called "upstream".

Most of the time I work on upstream but occasionally, I'll push
something to the fork and generate a PR to obtain feedback.

I also use the fork if I need to share in-progress work between my
desktop and laptop.

I use upstream so much I should probably reconfigure the names of the
remotes in my checkout:
origin -> fork
upstream -> origin

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] branch BZ-63835/8.5.x created (now 6ff2233)

Posted by Michael Osipov <mi...@apache.org>.
Am 2019-10-11 um 16:07 schrieb Rémy Maucherat:
> On Fri, Oct 11, 2019 at 3:46 PM Michael Osipov <mi...@apache.org> wrote:
> 
>> Am 2019-10-11 um 15:10 schrieb Rémy Maucherat:
>>> On Fri, Oct 11, 2019 at 1:51 PM Michael Osipov <mi...@apache.org>
>> wrote:
>>>
>>>> Am 2019-10-11 um 11:32 schrieb Rémy Maucherat:
>>>>> On Fri, Oct 11, 2019 at 10:43 AM Mark Thomas <ma...@apache.org> wrote:
>>>>>
>>>>>> On 11/10/2019 09:30, michaelo@apache.org wrote:
>>>>>>> This is an automated email from the ASF dual-hosted git repository.
>>>>>>>
>>>>>>> michaelo pushed a change to branch BZ-63835/8.5.x
>>>>>>
>>>>>> New features should be implemented against master and then back-ported
>>>>>> (assuming the community accepts them).
>>>>>>
>>>>>
>>>>> I also (still) prefer either PRs (it allows comments) or in master.
>>>>
>>>> This is a first draft, nothing PR worthy. As soon as I see the code
>>>> working, I will create the PR by then and when approved in general I
>>>> will add tests and re-request review. So please be patient.
>>>>
>>>
>>> For this use I'd recommend using your own forked repository then. Using a
>>> branch for that doesn't work for me, it sends way too many emails that
>> are
>>> not actually useful to dev to the dev mailing list. I tried for a while,
>> it
>>> didn't work, sorry :(
>>
>> I am not really convinced by this and I will tell you why:
>>
>> * Other TLPs have a commits@ for this
>> * The purpose of branches is exactly to work on something
>> * Having it in a fork would take the ability away that people instantly
>> notice my intermediate changes in a canonical location and leave
>> valuable comments as you did guys. No one will look at my fork as long
>> as I don't request it. I rather fix an issue early than two weeks later
>> in the PR.
>>
> 
> I disagree with this so I will draft and hold a formal vote on this to
> clarify the rules regarding the use of private branches.

Sounds reasonable.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] branch BZ-63835/8.5.x created (now 6ff2233)

Posted by Rémy Maucherat <re...@apache.org>.
On Fri, Oct 11, 2019 at 3:46 PM Michael Osipov <mi...@apache.org> wrote:

> Am 2019-10-11 um 15:10 schrieb Rémy Maucherat:
> > On Fri, Oct 11, 2019 at 1:51 PM Michael Osipov <mi...@apache.org>
> wrote:
> >
> >> Am 2019-10-11 um 11:32 schrieb Rémy Maucherat:
> >>> On Fri, Oct 11, 2019 at 10:43 AM Mark Thomas <ma...@apache.org> wrote:
> >>>
> >>>> On 11/10/2019 09:30, michaelo@apache.org wrote:
> >>>>> This is an automated email from the ASF dual-hosted git repository.
> >>>>>
> >>>>> michaelo pushed a change to branch BZ-63835/8.5.x
> >>>>
> >>>> New features should be implemented against master and then back-ported
> >>>> (assuming the community accepts them).
> >>>>
> >>>
> >>> I also (still) prefer either PRs (it allows comments) or in master.
> >>
> >> This is a first draft, nothing PR worthy. As soon as I see the code
> >> working, I will create the PR by then and when approved in general I
> >> will add tests and re-request review. So please be patient.
> >>
> >
> > For this use I'd recommend using your own forked repository then. Using a
> > branch for that doesn't work for me, it sends way too many emails that
> are
> > not actually useful to dev to the dev mailing list. I tried for a while,
> it
> > didn't work, sorry :(
>
> I am not really convinced by this and I will tell you why:
>
> * Other TLPs have a commits@ for this
> * The purpose of branches is exactly to work on something
> * Having it in a fork would take the ability away that people instantly
> notice my intermediate changes in a canonical location and leave
> valuable comments as you did guys. No one will look at my fork as long
> as I don't request it. I rather fix an issue early than two weeks later
> in the PR.
>

I disagree with this so I will draft and hold a formal vote on this to
clarify the rules regarding the use of private branches.

Rémy

Re: [tomcat] branch BZ-63835/8.5.x created (now 6ff2233)

Posted by Michael Osipov <mi...@apache.org>.
Am 2019-10-11 um 15:10 schrieb Rémy Maucherat:
> On Fri, Oct 11, 2019 at 1:51 PM Michael Osipov <mi...@apache.org> wrote:
> 
>> Am 2019-10-11 um 11:32 schrieb Rémy Maucherat:
>>> On Fri, Oct 11, 2019 at 10:43 AM Mark Thomas <ma...@apache.org> wrote:
>>>
>>>> On 11/10/2019 09:30, michaelo@apache.org wrote:
>>>>> This is an automated email from the ASF dual-hosted git repository.
>>>>>
>>>>> michaelo pushed a change to branch BZ-63835/8.5.x
>>>>
>>>> New features should be implemented against master and then back-ported
>>>> (assuming the community accepts them).
>>>>
>>>
>>> I also (still) prefer either PRs (it allows comments) or in master.
>>
>> This is a first draft, nothing PR worthy. As soon as I see the code
>> working, I will create the PR by then and when approved in general I
>> will add tests and re-request review. So please be patient.
>>
> 
> For this use I'd recommend using your own forked repository then. Using a
> branch for that doesn't work for me, it sends way too many emails that are
> not actually useful to dev to the dev mailing list. I tried for a while, it
> didn't work, sorry :(

I am not really convinced by this and I will tell you why:

* Other TLPs have a commits@ for this
* The purpose of branches is exactly to work on something
* Having it in a fork would take the ability away that people instantly 
notice my intermediate changes in a canonical location and leave 
valuable comments as you did guys. No one will look at my fork as long 
as I don't request it. I rather fix an issue early than two weeks later 
in the PR.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] branch BZ-63835/8.5.x created (now 6ff2233)

Posted by Rémy Maucherat <re...@apache.org>.
On Fri, Oct 11, 2019 at 1:51 PM Michael Osipov <mi...@apache.org> wrote:

> Am 2019-10-11 um 11:32 schrieb Rémy Maucherat:
> > On Fri, Oct 11, 2019 at 10:43 AM Mark Thomas <ma...@apache.org> wrote:
> >
> >> On 11/10/2019 09:30, michaelo@apache.org wrote:
> >>> This is an automated email from the ASF dual-hosted git repository.
> >>>
> >>> michaelo pushed a change to branch BZ-63835/8.5.x
> >>
> >> New features should be implemented against master and then back-ported
> >> (assuming the community accepts them).
> >>
> >
> > I also (still) prefer either PRs (it allows comments) or in master.
>
> This is a first draft, nothing PR worthy. As soon as I see the code
> working, I will create the PR by then and when approved in general I
> will add tests and re-request review. So please be patient.
>

For this use I'd recommend using your own forked repository then. Using a
branch for that doesn't work for me, it sends way too many emails that are
not actually useful to dev to the dev mailing list. I tried for a while, it
didn't work, sorry :(

So either:
- a PR
- directly in master
- your git fork

Rémy

Re: [tomcat] branch BZ-63835/8.5.x created (now 6ff2233)

Posted by Michael Osipov <mi...@apache.org>.
Am 2019-10-11 um 11:32 schrieb Rémy Maucherat:
> On Fri, Oct 11, 2019 at 10:43 AM Mark Thomas <ma...@apache.org> wrote:
> 
>> On 11/10/2019 09:30, michaelo@apache.org wrote:
>>> This is an automated email from the ASF dual-hosted git repository.
>>>
>>> michaelo pushed a change to branch BZ-63835/8.5.x
>>
>> New features should be implemented against master and then back-ported
>> (assuming the community accepts them).
>>
> 
> I also (still) prefer either PRs (it allows comments) or in master.

This is a first draft, nothing PR worthy. As soon as I see the code 
working, I will create the PR by then and when approved in general I 
will add tests and re-request review. So please be patient.

Michael


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] branch BZ-63835/8.5.x created (now 6ff2233)

Posted by Rémy Maucherat <re...@apache.org>.
On Fri, Oct 11, 2019 at 10:43 AM Mark Thomas <ma...@apache.org> wrote:

> On 11/10/2019 09:30, michaelo@apache.org wrote:
> > This is an automated email from the ASF dual-hosted git repository.
> >
> > michaelo pushed a change to branch BZ-63835/8.5.x
>
> New features should be implemented against master and then back-ported
> (assuming the community accepts them).
>

I also (still) prefer either PRs (it allows comments) or in master.

Rémy


>
> Mark
>
>
> > in repository https://gitbox.apache.org/repos/asf/tomcat.git.
> >
> >
> >       at 6ff2233  First draft
> >
> > This branch includes the following new commits:
> >
> >      new 6ff2233  First draft
> >
> > The 1 revisions listed above as "new" are entirely new to this
> > repository and will be described in separate emails.  The revisions
> > listed as "add" were already present in the repository and have only
> > been added to this reference.
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: dev-help@tomcat.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

Re: [tomcat] branch BZ-63835/8.5.x created (now 6ff2233)

Posted by Mark Thomas <ma...@apache.org>.
On 11/10/2019 09:30, michaelo@apache.org wrote:
> This is an automated email from the ASF dual-hosted git repository.
> 
> michaelo pushed a change to branch BZ-63835/8.5.x

New features should be implemented against master and then back-ported
(assuming the community accepts them).

Mark


> in repository https://gitbox.apache.org/repos/asf/tomcat.git.
> 
> 
>       at 6ff2233  First draft
> 
> This branch includes the following new commits:
> 
>      new 6ff2233  First draft
> 
> The 1 revisions listed above as "new" are entirely new to this
> repository and will be described in separate emails.  The revisions
> listed as "add" were already present in the repository and have only
> been added to this reference.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] 01/01: First draft

Posted by Michael Osipov <mi...@apache.org>.
Am 2019-10-11 um 14:35 schrieb Rémy Maucherat:
> On Fri, Oct 11, 2019 at 1:49 PM Michael Osipov <mi...@apache.org> wrote:
> 
>> Am 2019-10-11 um 11:51 schrieb Rémy Maucherat:
>>> On Fri, Oct 11, 2019 at 10:30 AM <mi...@apache.org> wrote:
>>>
>>>> This is an automated email from the ASF dual-hosted git repository.
>>>>
>>>> michaelo pushed a commit to branch BZ-63835/8.5.x
>>>> in repository https://gitbox.apache.org/repos/asf/tomcat.git
>>>>
>>>> commit 6ff2233cbbd27c9c2c649208a21931e5f3e132a6
>>>> Author: Michael Osipov <mi...@apache.org>
>>>> AuthorDate: Fri Oct 11 10:30:08 2019 +0200
>>>>
>>>>       First draft
>>>>
>>>
>>> +                if (keepAliveTimeout > 0) {
>>> +                    String value = "timeout=" +
>>> TimeUnit.MILLISECONDS.toSeconds(keepAliveTimeout);
>>> +
>>> +                    if (maxKeepAliveRequests > 0) {
>>> +                        value += ", max=" + maxKeepAliveRequests;
>>> +                    }
>>> StringBuilder ?
>>
>> StringBuilder does not make any sense because:
>>
>> * The compiler will replace the static code automatically with a
>> StringBuilder
>> * StringBuilder gains benefit when you concat strings in a for/while/do
>> loop. The above code is purely static.
>>
> 
> I don't understand how this can work, or how it is static, but if you're
> 100% certain it's fine.

Please look here: 
https://dzone.com/articles/string-concatenation-performacne-improvement-in-ja

Exactly the same case.

>>> Can you add a new flag controlling the feature ? The information may not
>> be
>>> very useful in many cases such as when proxying, so it would be better to
>>> skip generating it by default.
>>
>> This is -- as documented -- a first draft.
>>
>> As mentioned on the ticket. This is hop-by-hop and writetn only if the
>> client requests this piece of information. We can surely discuss a flag
>> for this on the connector.
>>
> 
> Ok indeed. I never understood why some clients kept sending Connection:
> keep-alive since it was also not needed.

To be honest, I didn't know either until I started digging for the 
client problem a colleague had.

Try against HTTPd and you'll see even with HTTP 1.1 client.


Michael


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] 01/01: First draft

Posted by Rémy Maucherat <re...@apache.org>.
On Fri, Oct 11, 2019 at 1:49 PM Michael Osipov <mi...@apache.org> wrote:

> Am 2019-10-11 um 11:51 schrieb Rémy Maucherat:
> > On Fri, Oct 11, 2019 at 10:30 AM <mi...@apache.org> wrote:
> >
> >> This is an automated email from the ASF dual-hosted git repository.
> >>
> >> michaelo pushed a commit to branch BZ-63835/8.5.x
> >> in repository https://gitbox.apache.org/repos/asf/tomcat.git
> >>
> >> commit 6ff2233cbbd27c9c2c649208a21931e5f3e132a6
> >> Author: Michael Osipov <mi...@apache.org>
> >> AuthorDate: Fri Oct 11 10:30:08 2019 +0200
> >>
> >>      First draft
> >>
> >
> > +                if (keepAliveTimeout > 0) {
> > +                    String value = "timeout=" +
> > TimeUnit.MILLISECONDS.toSeconds(keepAliveTimeout);
> > +
> > +                    if (maxKeepAliveRequests > 0) {
> > +                        value += ", max=" + maxKeepAliveRequests;
> > +                    }
> > StringBuilder ?
>
> StringBuilder does not make any sense because:
>
> * The compiler will replace the static code automatically with a
> StringBuilder
> * StringBuilder gains benefit when you concat strings in a for/while/do
> loop. The above code is purely static.
>

I don't understand how this can work, or how it is static, but if you're
100% certain it's fine.


>
> > Can you add a new flag controlling the feature ? The information may not
> be
> > very useful in many cases such as when proxying, so it would be better to
> > skip generating it by default.
>
> This is -- as documented -- a first draft.
>
> As mentioned on the ticket. This is hop-by-hop and writetn only if the
> client requests this piece of information. We can surely discuss a flag
> for this on the connector.
>

Ok indeed. I never understood why some clients kept sending Connection:
keep-alive since it was also not needed.

Rémy

Re: [tomcat] 01/01: First draft

Posted by Michael Osipov <mi...@apache.org>.
Am 2019-10-11 um 11:51 schrieb Rémy Maucherat:
> On Fri, Oct 11, 2019 at 10:30 AM <mi...@apache.org> wrote:
> 
>> This is an automated email from the ASF dual-hosted git repository.
>>
>> michaelo pushed a commit to branch BZ-63835/8.5.x
>> in repository https://gitbox.apache.org/repos/asf/tomcat.git
>>
>> commit 6ff2233cbbd27c9c2c649208a21931e5f3e132a6
>> Author: Michael Osipov <mi...@apache.org>
>> AuthorDate: Fri Oct 11 10:30:08 2019 +0200
>>
>>      First draft
>>
> 
> +                if (keepAliveTimeout > 0) {
> +                    String value = "timeout=" +
> TimeUnit.MILLISECONDS.toSeconds(keepAliveTimeout);
> +
> +                    if (maxKeepAliveRequests > 0) {
> +                        value += ", max=" + maxKeepAliveRequests;
> +                    }
> StringBuilder ?

StringBuilder does not make any sense because:

* The compiler will replace the static code automatically with a 
StringBuilder
* StringBuilder gains benefit when you concat strings in a for/while/do 
loop. The above code is purely static.

> Can you add a new flag controlling the feature ? The information may not be
> very useful in many cases such as when proxying, so it would be better to
> skip generating it by default.

This is -- as documented -- a first draft.

As mentioned on the ticket. This is hop-by-hop and writetn only if the 
client requests this piece of information. We can surely discuss a flag 
for this on the connector.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] 01/01: First draft

Posted by Rémy Maucherat <re...@apache.org>.
On Fri, Oct 11, 2019 at 10:30 AM <mi...@apache.org> wrote:

> This is an automated email from the ASF dual-hosted git repository.
>
> michaelo pushed a commit to branch BZ-63835/8.5.x
> in repository https://gitbox.apache.org/repos/asf/tomcat.git
>
> commit 6ff2233cbbd27c9c2c649208a21931e5f3e132a6
> Author: Michael Osipov <mi...@apache.org>
> AuthorDate: Fri Oct 11 10:30:08 2019 +0200
>
>     First draft
>

+                if (keepAliveTimeout > 0) {
+                    String value = "timeout=" +
TimeUnit.MILLISECONDS.toSeconds(keepAliveTimeout);
+
+                    if (maxKeepAliveRequests > 0) {
+                        value += ", max=" + maxKeepAliveRequests;
+                    }
StringBuilder ?

Can you add a new flag controlling the feature ? The information may not be
very useful in many cases such as when proxying, so it would be better to
skip generating it by default.

Rémy


> ---
>  java/org/apache/coyote/http11/Http11Processor.java | 36
> ++++++++++++++++++----
>  1 file changed, 30 insertions(+), 6 deletions(-)
>
> diff --git a/java/org/apache/coyote/http11/Http11Processor.java
> b/java/org/apache/coyote/http11/Http11Processor.java
> index 6072602..3182bb7 100644
> --- a/java/org/apache/coyote/http11/Http11Processor.java
> +++ b/java/org/apache/coyote/http11/Http11Processor.java
> @@ -23,6 +23,7 @@ import java.util.Enumeration;
>  import java.util.Locale;
>  import java.util.Map;
>  import java.util.Set;
> +import java.util.concurrent.TimeUnit;
>  import java.util.regex.Pattern;
>
>  import javax.servlet.http.HttpServletResponse;
> @@ -1307,7 +1308,7 @@ public class Http11Processor extends
> AbstractProcessor {
>          } else {
>              // If the response code supports an entity body and we're on
>              // HTTP 1.1 then we chunk unless we have a Connection: close
> header
> -            connectionClosePresent = isConnectionClose(headers);
> +            connectionClosePresent = isConnectionValue(headers,
> Constants.CLOSE);
>              if (entityBody && http11 && !connectionClosePresent) {
>                  outputBuffer.addActiveFilter
>                      (outputFilters[Constants.CHUNKED_FILTER]);
> @@ -1369,10 +1370,33 @@ public class Http11Processor extends
> AbstractProcessor {
>                  headers.addValue(Constants.CONNECTION).setString(
>                          Constants.CLOSE);
>              }
> -        } else if (!http11 && !getErrorState().isError()) {
> -
> headers.addValue(Constants.CONNECTION).setString(Constants.KEEPALIVE);
> -        }
> +        } else if (!getErrorState().isError()) {
> +            if (!http11) {
> +
> headers.addValue(Constants.CONNECTION).setString(Constants.KEEPALIVE);
> +            }
> +
> +            boolean connectionKeepAlivePresent =
> +                isConnectionValue(request.getMimeHeaders(),
> Constants.KEEPALIVE);
> +
> +            if (connectionKeepAlivePresent) {
> +                int keepAliveTimeout = endpoint.getKeepAliveTimeout();
> +                int maxKeepAliveRequests = getMaxKeepAliveRequests();
> +
> +                if (keepAliveTimeout > 0) {
> +                    String value = "timeout=" +
> TimeUnit.MILLISECONDS.toSeconds(keepAliveTimeout);
> +
> +                    if (maxKeepAliveRequests > 0) {
> +                        value += ", max=" + maxKeepAliveRequests;
> +                    }
>
> +                    headers.setValue("Keep-Alive").setString(value);
> +                }
> +
> +                if (http11) {
> +
> headers.addValue(Constants.CONNECTION).setString(Constants.KEEPALIVE);
> +                }
> +            }
> +        }
>          // Add server header
>          if (server == null) {
>              if (serverRemoveAppProvidedValues) {
> @@ -1403,12 +1427,12 @@ public class Http11Processor extends
> AbstractProcessor {
>          outputBuffer.commit();
>      }
>
> -    private static boolean isConnectionClose(MimeHeaders headers) {
> +    private static boolean isConnectionValue(MimeHeaders headers, String
> value) {
>          MessageBytes connection = headers.getValue(Constants.CONNECTION);
>          if (connection == null) {
>              return false;
>          }
> -        return connection.equals(Constants.CLOSE);
> +        return connection.equals(value);
>      }
>
>      private void prepareSendfile(OutputFilter[] outputFilters) {
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

[tomcat] 01/01: First draft

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch BZ-63835/8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 6ff2233cbbd27c9c2c649208a21931e5f3e132a6
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Fri Oct 11 10:30:08 2019 +0200

    First draft
---
 java/org/apache/coyote/http11/Http11Processor.java | 36 ++++++++++++++++++----
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java
index 6072602..3182bb7 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -23,6 +23,7 @@ import java.util.Enumeration;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 import java.util.regex.Pattern;
 
 import javax.servlet.http.HttpServletResponse;
@@ -1307,7 +1308,7 @@ public class Http11Processor extends AbstractProcessor {
         } else {
             // If the response code supports an entity body and we're on
             // HTTP 1.1 then we chunk unless we have a Connection: close header
-            connectionClosePresent = isConnectionClose(headers);
+            connectionClosePresent = isConnectionValue(headers, Constants.CLOSE);
             if (entityBody && http11 && !connectionClosePresent) {
                 outputBuffer.addActiveFilter
                     (outputFilters[Constants.CHUNKED_FILTER]);
@@ -1369,10 +1370,33 @@ public class Http11Processor extends AbstractProcessor {
                 headers.addValue(Constants.CONNECTION).setString(
                         Constants.CLOSE);
             }
-        } else if (!http11 && !getErrorState().isError()) {
-            headers.addValue(Constants.CONNECTION).setString(Constants.KEEPALIVE);
-        }
+        } else if (!getErrorState().isError()) {
+            if (!http11) {
+                headers.addValue(Constants.CONNECTION).setString(Constants.KEEPALIVE);
+            }
+
+            boolean connectionKeepAlivePresent =
+                isConnectionValue(request.getMimeHeaders(), Constants.KEEPALIVE);
+
+            if (connectionKeepAlivePresent) {
+                int keepAliveTimeout = endpoint.getKeepAliveTimeout();
+                int maxKeepAliveRequests = getMaxKeepAliveRequests();
+
+                if (keepAliveTimeout > 0) {
+                    String value = "timeout=" + TimeUnit.MILLISECONDS.toSeconds(keepAliveTimeout);
+
+                    if (maxKeepAliveRequests > 0) {
+                        value += ", max=" + maxKeepAliveRequests;
+                    }
 
+                    headers.setValue("Keep-Alive").setString(value);
+                }
+
+                if (http11) {
+                    headers.addValue(Constants.CONNECTION).setString(Constants.KEEPALIVE);
+                }
+            }
+        }
         // Add server header
         if (server == null) {
             if (serverRemoveAppProvidedValues) {
@@ -1403,12 +1427,12 @@ public class Http11Processor extends AbstractProcessor {
         outputBuffer.commit();
     }
 
-    private static boolean isConnectionClose(MimeHeaders headers) {
+    private static boolean isConnectionValue(MimeHeaders headers, String value) {
         MessageBytes connection = headers.getValue(Constants.CONNECTION);
         if (connection == null) {
             return false;
         }
-        return connection.equals(Constants.CLOSE);
+        return connection.equals(value);
     }
 
     private void prepareSendfile(OutputFilter[] outputFilters) {


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org