Java httpserver
I have grinded a while, I finally decided to still start working.
Today, I will make Java's httpserver. Looking for a few httpserver code, it is not too complex to solve the problem of learning curve is not very applicable, just write it yourself. Anyway, it is not intended to write complicated, as long as you can handle simple Get / POST requests, you can output the HTML page through the template.
(Above is written 1:49)
Now the basic HTTP function has been completed, with the following Class
TCPSERVER: Thread implements TCPSocket server, processing accept
TCPSERVERHANDAL: THREAD ACCEPT is over, the new connection is handed over to TCPServerHandler processing
HTTPSERVER: TCPServer call httpserverhandler
HTTPSERVERHANDAL: TCPSERVERHANDAL: TCPSERVERHANDAL: HTTP requests to implement service (httpRequest, httpresponse)
HttpRequest: Receive and parse the HTTP request, currently only support GET / POST operation
HTTPRESPONSE: assemble HTTP response clasp, output return page
PageContainer: Page Template Loading and Buffer Container
PageTemplate: page template, realize limited dynamic pages in a string (loop output table is slightly complex, don't play first)
In addition, 8 cigarettes were pumped, and there were countless cups of water, read half of the movie and replied several Email, modified a bug of other projects. It is still more fulfilling.
Todo List:
1: TCPServer stability, abnormal discontinuation detection and processing.
2: The HTTP protocol itself character transcoding, including Chinese characters and reserved characters such as <> &? ...
3: Java's Chinese character processing
4: Run httpserver and pushserver, and business connection
5: Other details Control and class, Iterative Reconstruction of Interface