String udn = request.getParameter("icon"); //$NON-NLS-1$
if (udn != null)
{
UPnPIcon icon = (UPnPIcon) icons.get(udn);
if (icon == null)
{
response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
else
{
if (request.getDateHeader("If-Modified-Since") > 0) //$NON-NLS-1$
{
// if it is already in cache - don't bother to go further
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
}
else
{
// enable caching
response.setDateHeader("Last-Modified", LAST_MODIFIED); //$NON-NLS-1$
InputStream in = icon.getInputStream();
if (null == in)
{ // this is buggy implementations
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
String mime = icon.getMimeType();
if (mime != null)
response.setContentType(mime);
OutputStream out = response.getOutputStream();
int size = icon.getSize();
if (size > 0)
response.setContentLength(size);
// can't use buffer, because it's might block if reading byte[]
int read;