GithubHelp home page GithubHelp logo

jhttpsrv's Introduction

jhttpsrv

A small http server written in Java.

Required Software

Gradle can be installed via Homebrew.

brew install gradle

Running the Tests

gradle test --info

Creating the Jar

gradle jar

Running the Server

java -jar build/libs/jhttpsrv-$VERSION.jar

By default, the server runs on port 8080 and tries to use $CURRENT-WORKING-DIR/www/ as a root directory from which to serve files.

These options can be changed with --port and --directory. Short options (-p and -d) are also supported.

Example: Serve files from /var/www on port 9090.

java -jar build/libs/jhttpsrv-$VERSION.jar -p 9090 -d /var/www

jhttpsrv's People

Contributors

j8th avatar

Watchers

James Cloos avatar  avatar

jhttpsrv's Issues

Test Failure on Clean Build

I got a failure when I ran the tests for the server the first time. I ran it a second time and it worked without failure. I was able to reproduce the error by doing gradle clean and then running the specs.

$ gradle test --info
Starting Build
Settings evaluated using settings file '/Users/sandropadin/code/j8th/jhttpsrv/settings.gradle'.
Projects loaded. Root project using build file '/Users/sandropadin/code/j8th/jhttpsrv/build.gradle'.
Included projects: [root project 'jhttpsrv']
Evaluating root project 'jhttpsrv' using build file '/Users/sandropadin/code/j8th/jhttpsrv/build.gradle'.
All projects evaluated.
Selected primary task 'test' from project :
Tasks to be executed: [task ':compileJava', task ':processResources', task ':classes', task ':compileTestJava', task ':processTestResources', task ':testClasses', task ':test']
:compileJava (Thread[main,5,main]) started.
:compileJava
Executing task ':compileJava' (up-to-date check took 0.085 secs) due to:
  Input file /Users/sandropadin/code/j8th/jhttpsrv/src/main/java/com/eighthlight/jhttpsrv/handler/FileRequestHandler.java has changed.
  Input file /Users/sandropadin/code/j8th/jhttpsrv/src/main/java/com/eighthlight/jhttpsrv/handler/TimeRequestHandler.java has changed.
  Input file /Users/sandropadin/code/j8th/jhttpsrv/src/main/java/com/eighthlight/jhttpsrv/response/ResponseBody.java has changed.
Compiling with JDK Java compiler API.
:compileJava (Thread[main,5,main]) completed. Took 0.955 secs.
:processResources (Thread[main,5,main]) started.
:processResources
Skipping task ':processResources' as it has no source files.
:processResources UP-TO-DATE
:processResources (Thread[main,5,main]) completed. Took 0.002 secs.
:classes (Thread[main,5,main]) started.
:classes
Skipping task ':classes' as it has no actions.
:classes (Thread[main,5,main]) completed. Took 0.001 secs.
:compileTestJava (Thread[main,5,main]) started.
:compileTestJava
Download https://repo1.maven.org/maven2/org/mockito/mockito-core/1.10.19/mockito-core-1.10.19.pom
Found locally available resource with matching checksum: [https://jcenter.bintray.com/org/mockito/mockito-core/1.10.19/mockito-core-1.10.19.pom, /Users/sandropadin/.gradle/caches/modules-2/files-2.1/org.mockito/mockito-core/1.10.19/228d760941af5e4c6e772d8761794aefe555da22/mockito-core-1.10.19.pom]
Download https://repo1.maven.org/maven2/org/mockito/mockito-core/1.10.19/mockito-core-1.10.19.jar
Executing task ':compileTestJava' (up-to-date check took 2.045 secs) due to:
  Input file /Users/sandropadin/code/j8th/jhttpsrv/src/test/java/com/eighthlight/jhttpsrv/testmessage/chrome/TestRequestMaker.java has changed.
  Input file /Users/sandropadin/code/j8th/jhttpsrv/build/classes/main/com/eighthlight/jhttpsrv/constants/StatusCodes.class has been added.
  Input file /Users/sandropadin/code/j8th/jhttpsrv/src/test/java/com/eighthlight/jhttpsrv/router/RouterTest.java has changed.
Compiling with JDK Java compiler API.
Note: /Users/sandropadin/code/j8th/jhttpsrv/src/test/java/com/eighthlight/jhttpsrv/request/RequestHeaderTest.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:compileTestJava (Thread[main,5,main]) completed. Took 2.309 secs.
:processTestResources (Thread[main,5,main]) started.
:processTestResources
Skipping task ':processTestResources' as it has no source files.
:processTestResources UP-TO-DATE
:processTestResources (Thread[main,5,main]) completed. Took 0.001 secs.
:testClasses (Thread[main,5,main]) started.
:testClasses
Skipping task ':testClasses' as it has no actions.
:testClasses (Thread[main,5,main]) completed. Took 0.001 secs.
:test (Thread[main,5,main]) started.
:test
Executing task ':test' (up-to-date check took 0.067 secs) due to:
  Value of input property 'candidateClassFiles' has changed for task ':test'
Starting process 'Gradle Test Executor 1'. Working directory: /Users/sandropadin/code/j8th/jhttpsrv Command: /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/bin/java -Djava.security.manager=jarjar.org.gradle.process.internal.child.BootstrapSecurityManager -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea -cp /Users/sandropadin/.gradle/caches/2.2.1/workerMain/gradle-worker.jar jarjar.org.gradle.process.internal.launcher.GradleWorkerMain 'Gradle Test Executor 1'
Successfully started process 'Gradle Test Executor 1'
Gradle Test Executor 1 started executing tests.

com.eighthlight.jhttpsrv.server.JhttpsrvTest > testRun STANDARD_ERROR
    Exception in thread "Thread-4" java.lang.NullPointerException

com.eighthlight.jhttpsrv.util.StringUtilsTest STANDARD_ERROR
        at com.eighthlight.jhttpsrv.worker.Worker.run(Worker.java:30)
        at com.eighthlight.jhttpsrv.server.Jhttpsrv.run(Jhttpsrv.java:34)
        at java.lang.Thread.run(Thread.java:745)
Gradle Test Executor 1 finished executing tests.
Finished generating test XML results (0.01 secs) into: /Users/sandropadin/code/j8th/jhttpsrv/build/test-results
Generating HTML test report...
Finished generating test html results (0.058 secs) into: /Users/sandropadin/code/j8th/jhttpsrv/build/reports/tests
:test (Thread[main,5,main]) completed. Took 3.219 secs.

BUILD SUCCESSFUL

Total time: 9.28 secs
Stopped 0 compiler daemon(s).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.