Skip to content

Instantly share code, notes, and snippets.

@NicoleCarpenter
Last active September 12, 2016 19:53
Show Gist options
  • Save NicoleCarpenter/3e14a54d36cce2fabb0febfdd5ff9710 to your computer and use it in GitHub Desktop.
Save NicoleCarpenter/3e14a54d36cce2fabb0febfdd5ff9710 to your computer and use it in GitHub Desktop.

Java HTTP Server Refactors

Refactor branch

  • Removes Response interface
  • Adds MockHttpRouter guts to test SetUp
  • Modifies RequestParserTest to remove unnecessary test cases and adds params tests
  • Uncomments testReadRequest() from HttpServerIOTest
  • Includes FileSystem as dependency for FileIO and adds update and delete tests for HttpFileIOTest
  • Adds ResponseBuilder interface and MockHttpResponseBuilder to test FileHandler

To Do

FileHandler

  • naming - handles both files and directories
  • html variables and formatting should be in a separate class
  • file extensions should be in separate class (also not tested)

FormHandler

  • if/else chain, consider another way to handle to reduce duplication
  • html formatting should be in separate class

MethodOptionsHandler

  • only passes cob spec, not actually doing what it should

HttpFileIO

  • Using Java PrintWriter and BufferedWriter classes, should be wrapped
  • testing - Tests ignored, can you test relative path instead of absolute?

HttpRequestParser

  • Does this class seem big to you?

HttpServer

  • testing - missing test file

HttpServerRunner

  • testing - missing test case for handleRouteCalled

RequestLog

  • Should this have more to it?
  • testing - missing test file
  • Note: /Users/foo/Desktop/coding/java/applications/JavaHttpServer/src/main/java/util/RequestLogger.java uses unchecked or unsafe operations.

Multi-threading

  • This fails every 10 threads or so. It is not something I know how to replicate.

Reveiw Board Notes

  • Missing test cases: TDD classes that have missing test cases (delete and TDD)
  • Server will become a library - 2 apps that will use this library, one that satisfies cob spec and one that works as an app that you can telnet into, leave a note (write to a file when you close telnet)
  • Problems: File names in router (only satisfying cob spec), can blow up
  • Request could be parsed into better objects
  • register 404 every time, can handle it once it is registered instead of constantly re-registering
  • open in Intellij to see squiggly stuff
  • file type checker breaks on pdf
  • sub-handlers from file handle
  • Config for setup from main, pass to router
  • Attach handler to router, router delegate to handler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment