I have a view in a Django application that automatically creates an image using PIL, saves it to a Nginx media server and returns an html template with an img tag pointing to its URL.
This works great, but I notice a problem. For every 5 times I get access to this view, in 1 of them the image is not displayed.
I did some research and I found something interesting, this is the HTTP response header when the image is displayed correctly:
Accept-Ranges:bytes
Connection:keep-alive
Content-Length:14966
Content-Type:image/jpeg
Date:Wed, 18 Aug 2010 15:36:16 GMT
Last-Modified:Wed, 18 Aug 2010 15:36:16 GMT
Server:nginx/0.5.33
and this is the title when the image does not load:
Accept-Ranges:bytes
Connection:keep-alive
Content-Length:0
Content-Type:image/jpeg
Date:Wed, 18 Aug 2010 15:37:47 GMT
Last-Modified:Wed, 18 Aug 2010 15:37:46 GMT
Server:nginx/0.5.33
Note that Content-Lenth is zero. What could be the reason for this? Any ideas on how I can further debug this issue?
Edit:
, "" . , ( ):
def draw(self):
if not self.image:
(fd, self.image) = tempfile.mkstemp(dir=settings.IMAGE_PATH, suffix=".jpeg")
fd2 = os.fdopen(fd, "wb")
else:
fd2 = open(os.path.join(settings.SITE_ROOT, self.image), "wb")
im = Image.new(mode, (width, height))
.....
im = im.resize((self.get_size_site(self.width),
self.get_size_site(self.height)))
im.save(fd2, "JPEG")
fd2.close()
Edit2: -:
http://xxxcnn7979.hospedagemdesites.ws:8000/cartao/99/
F5, .