Michael
Michael

Reputation: 10303

Partial reading of HTTP requests

Suppose I have a server (REST) application, which does not need to read fully incoming HTTP requests. Clients may send large HTTP requests of any size but I need only first X Kilobytes.

I would like to read only X Kilobytes and immediately close the connection. Does it make sense? Is it legal in terms of HTTP? What are alternatives?

Upvotes: 0

Views: 103

Answers (1)

arayq2
arayq2

Reputation: 2554

I would like to read only X Kilobytes and immediately close the connection. Does it make sense?

Not for a REST-ful application.

Is it legal in terms of HTTP?

Yes, technically. In the HTTP protocol a server response of some kind is always expected for a complete transaction. This will be experienced by the client as a premature ending of the connection, i.e. an incomplete or aborted transaction.

What are alternatives?

What are you trying to accomplish?

If you just want to read the first X bytes of whatever is sent by any client who connects and then not bother to reply at all, then the HTTP protocol is not for you, never mind REST.

Upvotes: 1

Related Questions