Alright so... so far the HTTP session has acted as both a connection and a request, the request part being reused once each request arrives. This has brought us to the current situation:
the class is massive, hard to navigate and near impossible to debug
it doesn't model any entity, by simultaneously attempting to model 2 different entities
unread bodies carry over to the next packet's head causing annoying errors
reusing fields causes all kinds of nasty issues when something slips past
probably a lot of other stuff as well
Therefore I propose to split it in the following way:
Each Request is read in the getNextRequest() method, that replaces execute() and parseBody(), automatically reading the full body and placing it in an appropriate place. The Request knows it's parent Connection, being able to link back to it in case you need to interact with the socket or read connection-wide informations.
We don't need to worry about the number of objects we're creating because the Garbage Collectors are smart enough to reuse them, since we'll be creating Request objects over and over and over again.
396 - getHostName() may cause a delay when client connects
The connection will now resolve this information the first time the method is used, storing it for future calls. This will stop the initial delay when the connection is opened.
376 - make parseBody() non-optional
this has already been explained above.
364 - getQueryParameterString is sticky
Not reusing the same object directly for request data will stop this kind of nonsense.
358 - Simplify the way Requests are passed to serve()
Requests are now actual objects. We can add the appropriate methods in the right places to also handle #333 #334 #335 #336 #337
356 - Send the request twice very fast,the second time will get "syntax error" message
We can now easily add chunked mode request support, dealing with things like this.
322 - Request takes very long on DHCP
Since hostname resolution will no longer be initiated automatically, this will probably be fixed as well
318 - Very slow loading in version 2.3.0
Yet another complaint of slow operation due to initial hostname resolution.
314 - Choosing not to session.parseBody() of certain requests causes body to carry over to next request
You can no longer not read the body, it won't carry over anymore.
211 - read post body in chunked mode
Again, chunked mode
Plus it will likely also fix some speed issues people have been complaining about.
Alright so... so far the HTTP session has acted as both a connection and a request, the request part being reused once each request arrives. This has brought us to the current situation:
Therefore I propose to split it in the following way:
Each
Request
is read in thegetNextRequest()
method, that replacesexecute()
andparseBody()
, automatically reading the full body and placing it in an appropriate place. TheRequest
knows it's parentConnection
, being able to link back to it in case you need to interact with the socket or read connection-wide informations.We don't need to worry about the number of objects we're creating because the Garbage Collectors are smart enough to reuse them, since we'll be creating
Request
objects over and over and over again.=========================================================
This will take care of the following issues:
396 - getHostName() may cause a delay when client connects
376 - make parseBody() non-optional
364 - getQueryParameterString is sticky
358 - Simplify the way Requests are passed to serve()
356 - Send the request twice very fast,the second time will get "syntax error" message
322 - Request takes very long on DHCP
318 - Very slow loading in version 2.3.0
314 - Choosing not to session.parseBody() of certain requests causes body to carry over to next request
211 - read post body in chunked mode
Plus it will likely also fix some speed issues people have been complaining about.
=========================================================
I think I've just hit the Mother Lode here. This looks like the biggest, baddest, nastiest cause of issues we've ever had.