Skip to content

Support for custom ServerSocketFactory #52

@buko

Description

@buko

Very cool project. This is sorely needed: a modern HTTP Server that doesn't use NIO.

It would be great if it were possible to use a custom ServerSocketFactory. This would not only simply the code and make it more testable but it would aksi allow the java-http project to be directly integrated into projects that work with custom Socket implementations (think P2P Overlay networks with custom TLS variants).

The Plan

Using a custom ServerSocketFactory would be straight forwards. HTTPListenerConfiguration.java would be modified to accept a ServerSocketFactory in its constructor and a public getServerSocketFactory() would be added to the class.

HTTPServerThread would be modified to accept this ServerSocketFactory in its constructor. Instead of hardcoding the creation of a new ServerSocket in the constructor (this.socket = new ServerSocket()) the HTTPServerThread should ask the ServerSocketFactory to create a new ServerSocket.

The Project would provide a DefaultServerSocketFactory and DefaultSSLServerSocketFactory.

ServerSocketFactory myCustomFactory = new MySpecializedServerSocketFactory();
HTTPListenerConfiguration listenerConfig = new HTTPListenerConfiguration(bindAddress, 8080, myCustomFactory);

HTTPServer server = new HTTPServer()
    .withConfiguration(new HTTPServerConfiguration()
        .withListener(listenerConfig)
        .withHandler(myHandler))
    .start();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions