nikkiii / embedhttp Goto Github PK
View Code? Open in Web Editor NEWA small, flexible and secure Java HTTP server which can be easily embedded into applications
License: MIT License
A small, flexible and secure Java HTTP server which can be easily embedded into applications
License: MIT License
serve don't close the connection after file upload.
Could we add a pom.xml
file detailing artifactId, version number, etc.? And publish to the Central Maven repository? I searched there for "embedhttp", but got no results.
The embedhttp is very nice for static http server, but how to implement file upload function?
File file = new File(documentRoot, request.getUri());
should be
File file = new File(documentRoot, uri);
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);
To provoke this error:
curl -I -X PUT http://host:port/
Result:
Uncaught Exception java.lang.IllegalArgumentException: PUT is not a constant in org.nikkii.embedhttp.impl.HttpMethod
When querying the server with an invalid HTTP method the server now responds with 405 Method not supported but then immediately crashes.
To provoke:
curl -I -X FOO http://10.0.0.21:8888/
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
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");
}
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();
}
}
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);
while ((read = input.read(b, totalRead, contentLength - totalRead)) > -1) {
totalRead += read;
}
the while above never terminate reading form data from input.
Hello,
Id like to create a HttpServer that only listens to localhost and found out how to do that:
http://stackoverflow.com/questions/2205073/how-to-create-java-socket-that-is-localhost-only
But Id need to set the socket manually. Could you add a bind() function to HttpServer that accepts the ServerSocket?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.