[SOLVED] Proper HTTP response for PNG

howdy,

I’ve been doing some work with backend java server programming (and progressive apps) and I have gotten to the point where I am deploying to Heroku. The problem is none of my icons are loading despite them loading in a local testing environment. Heroku is throwing an error code of H17 which I looked up and says that it has to do with the formatting of my HTTP response. The thing is my entire page loads perfectly except for the icons. I was wondering if anybody else has had an issue similar to this.

Http response format:


HTTP/1.1 200 OK
Content-Type: image/png
Connection: close

*raw image data*


this response works in a local environment (chrome: desktop and mobile)

full error


http_error="Invalid HTTP status line" 
at=error code=H17 
desc="Poorly formatted HTTP response" 
method=GET 
path="/img/icons/android-icon-36x36.png" 
host=*website* 
request_id=*id* 
fwd="*some ipv4 adress*" 
dyno=web.1 
connect=0ms service=2ms status=503 bytes=2482 protocol=https

I haven’t had your specific problem, but when I put my jsp web application on a server, missing mime types on the server caused errors that didn’t appear in my local machine.
How are you hosting the web app? In a tomcat server instance?

I’m not using any libraries or anything. Just using the java.net package with FreeMarker as a template engine.

In terms of mime types, my server can output text/* and the image/* types. and can handle get, post, put, and delete requests. I assumed this would at least be enough for testing and that I could add additional features as I need them.

Ok, well that sounds fine. Given that you problem only happens with PNG images, sounds like something’s wrong with your raw image data or the way it’s sent. I’d investigate the way Heroku send the raw image data and copy the way they do it.

It may be that Heroku has some annoying arbitrary restriction, so maybe try another host to see if the same error comes up.

Could also be worth trying other image formats such as JPEGs and see if that works.

Ok, so I fixed it. It seems you were half correct. While my header was valid and the way I was loading and sending image data was correct, I was sending the header as plain text and the image data as raw bytes. So Heroku didn’t know what to do and just stopped the connection altogether. Thanks!