File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need HTTP API

 
nige whit
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a server program that needs to process HTTP requests.
I COULD just write a servlet, and get the webserver to parse the HTTP headers, and bundle all the info up for me, but there will be no other servlets, this will be the only class that receives HTTP requests, so it doesn't seem worth having a whole webserver in the way just to pass HTTP requests to a single class! In fact I don't think the client will accept that.
What I need is an API which can parse an HTTP request, and allow me to extract all the info from it, and then allow me to construct and send a response.
This needs to be able to operate on SSL sockets.
Anyone know of where I can find one?
 
nige whit
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, thanks again. This IS a useful forum!
I found an open-source HTTP server at http://jigsaw.w3.org
The classes there can be persuaded to parse HTTP for you.
If anyone ever wants to know more.... well, just ask... it won't do you any good though!
 
Frank Carver
Sheriff
Posts: 6920
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm. I don't know quite why you didn't get any answers, but in my case I didn't reply because I only visit each forum maybe once a week, and have only just seen your question. Most on-line systems are slower at the weekends, too.
Anyway. If you are really looking for a very simple HTTP server component, you might find that the one from Jigsaw is too heavyweight. At its heart HTTP is an extremely simple protocol. The complexity only comes with all the later additions: cookies, keep-alive, etc. etc.
For an ultra-simple starting point, take a look at something like:
http://examples.oreilly.com/jenut/HttpMirror.java
If you don't need multi-threading, and just want to return a quick, simple result (like a status page), this is pretty much all you need.
For a slightly more complex threaded example, you could check out:
http://pont.net/socket/java/prog/httpServer.java
If you need much more than that, then you really ought to check out some of the better open source servlet servers. I recommend Jetty and paperclips as well-factored and thoughful implementations. Either of these will probably be easier to cannibalize for parts or strip down for your use than the big name open-source servers like Tomcat, Resin or Jigsaw.
I hope that helps.
 
nige whit
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Frank,
I will check those other things out. You're right, I need something very lightweight.
It's a little user authentication server. The username and URL are passed as parameters in the URL in a GET request, and I return the content as "true" or "false". All through SSL of course.
I realize that HTTP is quite simple. I could have knocked up a little class to read the headers, but parsing CR/CRLF/LF/space/":" delimited text can be just time consuming to get right, and I wanted to use something that already works.
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nigel -
Please change your screen name to conform to JavaRanch's naming policy.
Thanks,
 
nige whit
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've done that, but I don't see why I should.
The policy is that fictitious first and last names are OK. I gave a fictitious first/last name pair as "bike" and "rider" because that describes me.
What's the problem?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic