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
|
||||
res.setHeader ("Cache-Control", "no-cache"); // for HTTP 1.1
|
||||
}
|
||||
if ( trans.realm!=null )
|
||||
res.setHeader( "WWW-Authenticate", "Basic realm=\"" + trans.realm + "\"" );
|
||||
if ( trans.realm!=null )
|
||||
res.setHeader( "WWW-Authenticate", "Basic realm=\"" + trans.realm + "\"" );
|
||||
if (trans.status > 0)
|
||||
res.setStatus (trans.status);
|
||||
res.setContentLength (trans.getContentLength ());
|
||||
res.setContentType (trans.contentType);
|
||||
res.setContentLength (trans.getContentLength ());
|
||||
res.setContentType (trans.getContentType ());
|
||||
try {
|
||||
OutputStream out = res.getOutputStream ();
|
||||
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 {
|
||||
Cookie c = new Cookie(trans.getKeyAt(i), trans.getValueAt(i));
|
||||
Cookie c = new Cookie(trans.getKeyAt(i), trans.getValueAt(i));
|
||||
c.setPath ("/");
|
||||
if (cookieDomain != null)
|
||||
c.setDomain (cookieDomain);
|
||||
c.setDomain (cookieDomain);
|
||||
int expires = trans.getDaysAt(i);
|
||||
if (expires > 0)
|
||||
c.setMaxAge(expires * 60*60*24); // Cookie time to live, days -> seconds
|
||||
res.addCookie(c);
|
||||
c.setMaxAge(expires * 60*60*24); // Cookie time to live, days -> seconds
|
||||
res.addCookie(c);
|
||||
} catch (Exception ign) {}
|
||||
|
||||
if (trans.getRedirect () != null) {
|
||||
try {
|
||||
try {
|
||||
res.sendRedirect(trans.getRedirect ());
|
||||
} catch(Exception io_e) {}
|
||||
|
||||
|
@ -179,7 +179,7 @@ public class AcmeServletClient extends HttpServlet {
|
|||
if (trans.status > 0)
|
||||
res.setStatus (trans.status);
|
||||
res.setContentLength (trans.getContentLength ());
|
||||
res.setContentType (trans.contentType);
|
||||
res.setContentType (trans.getContentType ());
|
||||
try {
|
||||
OutputStream out = res.getOutputStream ();
|
||||
out.write (trans.getContent ());
|
||||
|
|
Loading…
Add table
Reference in a new issue