Skip to content

Latest commit

 

History

History
36 lines (30 loc) · 1.1 KB

File metadata and controls

36 lines (30 loc) · 1.1 KB

HttpTest

Some practice of Http

1.Structure

  • sources------html files
    else.html
    home.html
    index.html

  • src------src Java file

    • entity
      Response.java-- store the http request
      Request.java-- store the http response
    • Handler
      RequestHandler.java-- format the requset
      ResponseHandler.java-- format the response
    • threadtools
      Task.java-- use handler to deal with a accept
    • Main BootStrap.java-- listen, create thread to deal with the raw http request

2.Code implementation

  • create a socket to liten the port you will visit
  • when a visit is reaching, start a thread to deal with it, at the same time, main thread listen new accept
  • use some self-defined entity and method to format the http request and response

3.Start

the browser will display different content as you type different pages