Thought on HTTP header

Recently I have experienced ERR_EMPTY_RESPONSE error. Have you seen anything like this? This is a very rare case but also a very serious case. If you get this error, nothing will be received on the web brower. Nothing. No response. I’ll explain.

The problem has started from UPS API. We use the API to verify a commercial address. UPS returns whether it is correct or wrong as a SOAP format. I prefer JSON but XML is okay. But that was not the problem.

The problem was, UPS API’s response is chunked. If a HTTP response’s Transfer-Encoding is chunked, it does not designate how long this response is. This means the response could be very big or even infinite. So the receiver could wait forever.

For this long wait problem, many modern web browser like Chrome prohibits chunked response. They just ignore it. Nothing is processed.

I think they could set a certain time-out like 10 seconds or more. Our company’s API also uses time-out limit on the application level. But I understand that many librarys don’t want to use time-out.

Hikari also doesn’t allow to use timeout. They say it is not a database’s problem. It is entirely a develop’s problem. So they blame an application developer. This policy is also the same to C3PO, even though they allow time-out. But if you read the document of that, they also blame developers.

I understand that, it is actually a developer’s fault. Really. I know. But we developers are not perfect. So we want to mitigate our bugs using time-out technique.

But okay, Chrome doesn’t allow chunked response. So I had to specifically designate the required Content-length. It is not that hard. I put an additional code to count.

But, (how many buts I use in this article?) I also want to blame UPS. They just gave me a chunked response! Why do we have to count? But, (stop using buts any more… to me) I also understand they are also developers like me. Imperfect developers.

From UPS to our API to Web browsers, in this long route, this chunked response can be counted by one person at least. That develop could be a UPS’s developer, me, or Chrome’s developer. But Chrome has decided not to do that and I don’t want to request UPS. So I could do it. Okay. Done.

Loading

Published
Categorized as xacdo

By xacdo

Kyungwoo Hyun

Leave a comment

Your email address will not be published. Required fields are marked *