GithubHelp home page GithubHelp logo

nikkiii / embedhttp Goto Github PK

View Code? Open in Web Editor NEW
30.0 30.0 11.0 383 KB

A small, flexible and secure Java HTTP server which can be easily embedded into applications

License: MIT License

Java 100.00%

embedhttp's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

embedhttp's Issues

file upload

serve don't close the connection after file upload.

ThreadedResponseServer example

The ThreadedResponseServer example not working: the response "Hello, Word!" is returned to browser only one time, and not every second.. even with these modifications:

HttpResponse resp = new HttpResponse(HttpStatus.OK, "Hello, world!");
resp.addHeader("Connection","keep-alive");
request.getSession().sendResponse(resp, false);

multipart upload is broken

Hello, is this project still in development?

I was trying to implement POST multipart request for file uploading on a simple web server and I've take the MultipartReader.java from embedhttp.

It works great with text file or small image file, but with image >1MB (almost) the Reader "delete" some bytes or change arbitrary position bytes ("0x50" become "0x7F" and so on corrupting my PNG file).

On text file > 1MB nothing strange happend.

What do you think? I don't think it's an Encoding error because doesn't change all the 0x50

Content type issue

In case of using StaticFileHandler setting content type to "text/html" for every file prevents browser from recognizing its content (i.e. for css)

if (!resp.getHeaders().containsKey(HttpHeader.CONTENT_TYPE)) {
resp.addHeader(HttpHeader.CONTENT_TYPE, "text/html");
}

closing connection

It is possible o use the fact that connection are optionally closed after sending the response, to implement simple Comet long-poll style?

public void sendResponse(HttpResponse resp, boolean close) throws IOException {.
...
...
// Close it if required.
if (close) {
socket.close();
}
}

buffer length

in form post, the last field in querystring contains a blank byte, to correct this
the line 207 of HttpSession :

byte[] b = new byte[contentLength + 1];

must be :
byte[] b = new byte[contentLength];

the StaticFileHandler class also contains errors, line 55

documentRootPath = documentRootPath.substring(0, documentRootPath.length() - 2);

must be:

documentRootPath = documentRootPath.substring(0, documentRootPath.length() - 1);

line 60

requestPath = requestPath.substring(0, requestPath.length() - 2);

must be:

requestPath = requestPath.substring(0, requestPath.length() - 1);

post form

while ((read = input.read(b, totalRead, contentLength - totalRead)) > -1) {
totalRead += read;
}

the while above never terminate reading form data from input.

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.