tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Response.java
Date Sat, 26 May 2001 17:53:29 GMT
costin      01/05/26 10:53:29

  Modified:    src/share/org/apache/tomcat/core Response.java
  Log:
  Use standard name for the encoding.
  
  Don't set the charset encoding based on locale - this is not allways correct,
  the user should set it explicitely ( in many countries there are more than
  a possible encoding ).
  
  The code was also buggy, as it used to override the user setting.
  
  Revision  Changes    Path
  1.52      +15 -7     jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java
  
  Index: Response.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- Response.java	2001/05/23 03:09:21	1.51
  +++ Response.java	2001/05/26 17:53:29	1.52
  @@ -80,7 +80,7 @@
       
       public static final String DEFAULT_CONTENT_TYPE = "text/plain";
   
  -    public static final String DEFAULT_CHAR_ENCODING = "8859_1";
  +    public static final String DEFAULT_CHAR_ENCODING = "ISO-8859-1";
   
       public static final String LOCALE_DEFAULT="en";
   
  @@ -113,7 +113,7 @@
       // holds request error URI
       String errorURI=null;
   
  -    // 
  +    // content type set by user, not including encoding
       protected String contentType = DEFAULT_CONTENT_TYPE;
       protected String contentLanguage = null;
       protected String characterEncoding = DEFAULT_CHAR_ENCODING;
  @@ -410,6 +410,9 @@
           return locale;
       }
   
  +    /** Called explicitely by user to set the Content-Language and
  +     *  the default encoding
  +     */
       public void setLocale(Locale locale) {
           if (locale == null || included) {
               return;  // throw an exception?
  @@ -421,11 +424,16 @@
           // Set the contentLanguage for header output
           contentLanguage = locale.getLanguage();
   
  -        // Set the contentType for header output
  -        // Use the setContentType() method so encoding is set properly
  -        String newType = ContentType.constructLocalizedContentType(contentType,
  -								   locale);
  -        setContentType(newType);
  +	// Wrong: if setLocale is called after setContentType, it'll override
  +	// the user-value with the default value.
  +        // String newType = ContentType.constructLocalizedContentType(
  +	// contentType, locale);
  +	//        setContentType(newType);
  +
  +	// Guessing charset from language is inexact - it's better to
  +	// not do it.
  +	// setContentType must take priority
  +	//	characterEncoding = LocaleToCharsetMap.getCharset( locale );
   
   	// only one header !
   	headers.setValue("Content-Language").setString( contentLanguage);
  
  
  

Mime
View raw message