Use getContentType() method instead of directly accessing the
contentType field in ResponseTrans. The method will append the charset to the content type.
This commit is contained in:
		
							parent
							
								
									0a68003361
								
							
						
					
					
						commit
						77f29e6dfd
					
				
					 2 changed files with 11 additions and 11 deletions
				
			
		|  | @ -218,12 +218,12 @@ public abstract class AbstractServletClient extends HttpServlet { | ||||||
| 	        else | 	        else | ||||||
| 	            res.setHeader ("Cache-Control", "no-cache"); // for HTTP 1.1 | 	            res.setHeader ("Cache-Control", "no-cache"); // for HTTP 1.1 | ||||||
| 	    } | 	    } | ||||||
| 		if ( trans.realm!=null ) | 	    if ( trans.realm!=null ) | ||||||
| 			res.setHeader( "WWW-Authenticate", "Basic realm=\"" + trans.realm + "\"" ); | 	        res.setHeader( "WWW-Authenticate", "Basic realm=\"" + trans.realm + "\"" ); | ||||||
| 	    if (trans.status > 0) | 	    if (trans.status > 0) | ||||||
| 	        res.setStatus (trans.status); | 	        res.setStatus (trans.status); | ||||||
| 	    res.setContentLength (trans.getContentLength ());			 | 	    res.setContentLength (trans.getContentLength ()); | ||||||
| 	    res.setContentType (trans.contentType); | 	    res.setContentType (trans.getContentType ()); | ||||||
| 	    try { | 	    try { | ||||||
| 	        OutputStream out = res.getOutputStream (); | 	        OutputStream out = res.getOutputStream (); | ||||||
| 	        out.write (trans.getContent ()); | 	        out.write (trans.getContent ()); | ||||||
|  |  | ||||||
|  | @ -148,20 +148,20 @@ public class AcmeServletClient extends HttpServlet { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     private void writeResponse (HttpServletResponse res, ResponseTrans trans, Cookie[] cookies, String protocol) {			 |     private void writeResponse (HttpServletResponse res, ResponseTrans trans, Cookie[] cookies, String protocol) { | ||||||
| 	for (int i = 0; i < trans.countCookies(); i++) try { | 	for (int i = 0; i < trans.countCookies(); i++) try { | ||||||
| 	    Cookie c = new Cookie(trans.getKeyAt(i), trans.getValueAt(i));	 | 	    Cookie c = new Cookie(trans.getKeyAt(i), trans.getValueAt(i)); | ||||||
| 	    c.setPath ("/"); | 	    c.setPath ("/"); | ||||||
| 	    if (cookieDomain != null) | 	    if (cookieDomain != null) | ||||||
| 	        c.setDomain (cookieDomain);			 | 	        c.setDomain (cookieDomain); | ||||||
| 	    int expires = trans.getDaysAt(i); | 	    int expires = trans.getDaysAt(i); | ||||||
| 	    if (expires > 0) | 	    if (expires > 0) | ||||||
| 	        c.setMaxAge(expires * 60*60*24);   // Cookie time to live, days -> seconds	 | 	        c.setMaxAge(expires * 60*60*24);   // Cookie time to live, days -> seconds | ||||||
| 	    res.addCookie(c);				 | 	    res.addCookie(c); | ||||||
| 	} catch (Exception ign) {} | 	} catch (Exception ign) {} | ||||||
| 
 | 
 | ||||||
| 	if (trans.getRedirect () != null) { | 	if (trans.getRedirect () != null) { | ||||||
| 	    try {  | 	    try { | ||||||
| 	        res.sendRedirect(trans.getRedirect ()); | 	        res.sendRedirect(trans.getRedirect ()); | ||||||
| 	    } catch(Exception io_e) {} | 	    } catch(Exception io_e) {} | ||||||
| 
 | 
 | ||||||
|  | @ -179,7 +179,7 @@ public class AcmeServletClient extends HttpServlet { | ||||||
| 	    if (trans.status > 0) | 	    if (trans.status > 0) | ||||||
| 	        res.setStatus (trans.status); | 	        res.setStatus (trans.status); | ||||||
| 	    res.setContentLength (trans.getContentLength ());			 | 	    res.setContentLength (trans.getContentLength ());			 | ||||||
| 	    res.setContentType (trans.contentType); | 	    res.setContentType (trans.getContentType ()); | ||||||
| 	    try { | 	    try { | ||||||
| 	        OutputStream out = res.getOutputStream (); | 	        OutputStream out = res.getOutputStream (); | ||||||
| 	        out.write (trans.getContent ()); | 	        out.write (trans.getContent ()); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue