• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need HTTP API

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nigel -
Please change your screen name to conform to JavaRanch's naming policy.
Thanks,
 
nige whit
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic