//this.headers.put("content-type", "text/html");
this.headers.put("Last-Modified",
ftp.httpDateFormat.toString(ftpFile.getTimestamp()));
this.content = os.toByteArray();
MimeType contentType = null;
if (MAGIC) {
contentType = MIME.getMimeType(path, this.content);
} else {
contentType = MIME.getMimeType(path);
}
if (contentType != null) {
this.headers.put("Content-Type", contentType.getName());
}
// // approximate bytes sent and read
// if (this.httpAccounting != null) {
// this.httpAccounting.incrementBytesSent(path.length());
// this.httpAccounting.incrementBytesRead(this.content.length);
// }
this.code = 200; // http OK
} catch (FtpExceptionControlClosedByForcedDataClose e) {
// control connection is off, clean up
// ftp.client.disconnect();
if (ftp.followTalk)
Ftp.LOG.info("delete client because server cut off control channel: "+e);
ftp.client = null;
// in case this FtpExceptionControlClosedByForcedDataClose is
// thrown by retrieveList() (not retrieveFile()) above,
if (os == null) { // indicating throwing by retrieveList()
//throw new FtpException("fail to get attibutes: "+path);
Ftp.LOG.warning(
"Please try larger maxContentLength for ftp.client.retrieveList(). "
+ e);
// in a way, this is our request fault
this.code = 400; // http Bad request
return;
}
FTPFile ftpFile = (FTPFile) list.get(0);
this.headers.put("Content-Length",
new Long(ftpFile.getSize()).toString());
//this.headers.put("content-type", "text/html");
this.headers.put("Last-Modified",
ftp.httpDateFormat.toString(ftpFile.getTimestamp()));
this.content = os.toByteArray();
MimeType contentType = null;
if (MAGIC) {
contentType = MIME.getMimeType(path, this.content);
} else {
contentType = MIME.getMimeType(path);
}
if (contentType != null) {
this.headers.put("Content-Type", contentType.getName());
}
// // approximate bytes sent and read
// if (this.httpAccounting != null) {
// this.httpAccounting.incrementBytesSent(path.length());