added content-length and content-type header

This commit is contained in:
Sebastian Sdorra
2011-04-14 21:42:55 +02:00
parent 6c44c2ec27
commit 70ccf12081
2 changed files with 27 additions and 2 deletions

View File

@@ -110,6 +110,12 @@ public interface CGIExecutor
/** Field description */ /** Field description */
public static final String ENV_SERVER_SOFTWARE = "SERVER_SOFTWARE"; public static final String ENV_SERVER_SOFTWARE = "SERVER_SOFTWARE";
/** Field description */
public static final String REPSONSE_HEADER_CONTENT_LENGTH = "Content-Length";
/** Field description */
public static final String REPSONSE_HEADER_CONTENT_TYPE = "Content-Type";
/** Field description */ /** Field description */
public static final String RESPONSE_HEADER_HTTP_PREFIX = "HTTP"; public static final String RESPONSE_HEADER_HTTP_PREFIX = "HTTP";

View File

@@ -291,11 +291,30 @@ public class DefaultCGIExecutor extends AbstractCGIExecutor
String key = line.substring(0, k).trim(); String key = line.substring(0, k).trim();
String value = line.substring(k + 1).trim(); String value = line.substring(k + 1).trim();
if (RESPONSE_HEADER_LOCATION.equals(key)) if (RESPONSE_HEADER_LOCATION.equalsIgnoreCase(key))
{ {
response.sendRedirect(response.encodeRedirectURL(value)); response.sendRedirect(response.encodeRedirectURL(value));
} }
else if (RESPONSE_HEADER_STATUS.equals(key)) else if (REPSONSE_HEADER_CONTENT_TYPE.equalsIgnoreCase(key))
{
response.setContentType(value);
}
else if (REPSONSE_HEADER_CONTENT_LENGTH.equalsIgnoreCase(key))
{
try
{
response.setContentLength(Integer.parseInt(value));
}
catch (NumberFormatException ex)
{
if (logger.isDebugEnabled())
{
logger.debug(
"could not convert content-length header to integer", ex);
}
}
}
else if (RESPONSE_HEADER_STATUS.equalsIgnoreCase(key))
{ {
String[] token = value.split(" "); String[] token = value.split(" ");
int status = Integer.parseInt(token[0]); int status = Integer.parseInt(token[0]);