You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by jf...@apache.org on 2002/12/03 17:04:02 UTC

cvs commit: jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5 CoyoteResponse.java

jfarcand    2002/12/03 08:04:02

  Modified:    coyote/src/java/org/apache/coyote Response.java
               coyote/src/java/org/apache/coyote/tomcat5
                        CoyoteResponse.java
  Log:
  As Bill's recommends, do not set a default locale in Response directly.
  
  Revision  Changes    Path
  1.18      +4 -10     jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Response.java
  
  Index: Response.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Response.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Response.java	3 Dec 2002 02:29:14 -0000	1.17
  +++ Response.java	3 Dec 2002 16:04:02 -0000	1.18
  @@ -92,13 +92,7 @@
   
       // ----------------------------------------------------- Instance Variables
       
  -    
  -    /**
  -     * Default locale
  -     */
  -    private static Locale DEFAULT_LOCALE = new Locale("en", "US");
  -
  -    
  +       
       /**
        * Status code.
        */
  @@ -148,7 +142,7 @@
       protected String contentLanguage = null;
       protected String characterEncoding = Constants.DEFAULT_CHARACTER_ENCODING;
       protected int contentLength = -1;
  -    private Locale locale = DEFAULT_LOCALE;
  +    private Locale locale = null;
   
       /**
        * Holds request error exception.
  @@ -317,7 +311,7 @@
           // Reset the headers only if this is the main request,
           // not for included
           contentType = Constants.DEFAULT_CONTENT_TYPE;
  -        locale = DEFAULT_LOCALE;
  +        locale = null;
           contentLanguage = null;
           characterEncoding = Constants.DEFAULT_CHARACTER_ENCODING;
           contentLength = -1;
  @@ -531,7 +525,7 @@
           
           contentType = Constants.DEFAULT_CONTENT_TYPE;
           contentLanguage = null;
  -        locale = DEFAULT_LOCALE;
  +        locale = null;
           characterEncoding = Constants.DEFAULT_CHARACTER_ENCODING;
           contentLength = -1;
           status = 200;
  
  
  
  1.13      +14 -6     jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5/CoyoteResponse.java
  
  Index: CoyoteResponse.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5/CoyoteResponse.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- CoyoteResponse.java	3 Dec 2002 02:29:14 -0000	1.12
  +++ CoyoteResponse.java	3 Dec 2002 16:04:02 -0000	1.13
  @@ -136,7 +136,12 @@
   
       // ----------------------------------------------------- Instance Variables
   
  +   /**
  +     * Default locale as mandated by the spec.
  +     */
  +    private static Locale DEFAULT_LOCALE = new Locale("en", "US");
   
  +    
       /**
        * The date format we will use for creating date headers.
        */
  @@ -326,13 +331,13 @@
           error = false;
           isContentTypeSet = false;
           isCharacterEncodingSet = false;
  +        
           cookies.clear();
   
           if ((Constants.SECURITY) && (facade != null)) {
               facade.clear();
               facade = null;
           }
  -
       }
   
   
  @@ -607,6 +612,10 @@
        * Return the Locale assigned to this response.
        */
       public Locale getLocale() {
  +        // Lazy setting. If the local is null, then return the default one.
  +        if ( coyoteResponse.getLocale() == null){
  +            coyoteResponse.setLocale(DEFAULT_LOCALE);            
  +        }
           return (coyoteResponse.getLocale());
       }
   
  @@ -652,7 +661,6 @@
   
           coyoteResponse.reset();
           outputBuffer.reset();
  -
       }
   
   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5 CoyoteResponse.java

Posted by Remy Maucherat <re...@apache.org>.
Jeanfrancois Arcand wrote:
> 
> 
> Remy Maucherat wrote:
> 
>> jfarcand@apache.org wrote:
>>
>>> jfarcand    2002/12/03 08:04:02
>>>
>>>   Modified:    coyote/src/java/org/apache/coyote Response.java
>>>                coyote/src/java/org/apache/coyote/tomcat5
>>>                         CoyoteResponse.java
>>>   Log:
>>>   As Bill's recommends, do not set a default locale in Response 
>>> directly.
>>
>>
>>
>> That seems like a bad idea. AFAIK, a default locale was set before, 
>> and I removed it when I refactored the header handling; I think your 
>> patch was fine.
>>
>> OTOH, calling setLocale does not do the same thing (it ends up setting 
>> the content-language header, which may not be what you want to do). 
> 
> 
> That's true. What I'm trying to do is to only set the locale attribute 
> to confrom with the 2.4 spec. I will take a look at the spec 2.2/2.3. 
> I'm surprised there is no local by default.

I think I made a mistake when I removed the default locale. It was there 
in version 1.16. I think you should go back to version 1.17.

Remy


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5 CoyoteResponse.java

Posted by Jeanfrancois Arcand <jf...@apache.org>.

Remy Maucherat wrote:

> jfarcand@apache.org wrote:
>
>> jfarcand    2002/12/03 08:04:02
>>
>>   Modified:    coyote/src/java/org/apache/coyote Response.java
>>                coyote/src/java/org/apache/coyote/tomcat5
>>                         CoyoteResponse.java
>>   Log:
>>   As Bill's recommends, do not set a default locale in Response 
>> directly.
>
>
> That seems like a bad idea. AFAIK, a default locale was set before, 
> and I removed it when I refactored the header handling; I think your 
> patch was fine.

>
> OTOH, calling setLocale does not do the same thing (it ends up setting 
> the content-language header, which may not be what you want to do). 

That's true. What I'm trying to do is to only set the locale attribute 
to confrom with the 2.4 spec. I will take a look at the spec 2.2/2.3. 
I'm surprised there is no local by default.

-- Jeanfrancois

>
>
> Remy
>
>
> -- 
> To unsubscribe, e-mail:   
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5 CoyoteResponse.java

Posted by Remy Maucherat <re...@apache.org>.
jfarcand@apache.org wrote:
> jfarcand    2002/12/03 08:04:02
> 
>   Modified:    coyote/src/java/org/apache/coyote Response.java
>                coyote/src/java/org/apache/coyote/tomcat5
>                         CoyoteResponse.java
>   Log:
>   As Bill's recommends, do not set a default locale in Response directly.

That seems like a bad idea. AFAIK, a default locale was set before, and 
I removed it when I refactored the header handling; I think your patch 
was fine.
OTOH, calling setLocale does not do the same thing (it ends up setting 
the content-language header, which may not be what you want to do).

Remy


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>