I am looking for an HTTP library for C/C++, that handles only the protocol logic, instead of the actual transport mechanism. Libraries I've came across tend to incoperate the entire communication process, which is not what I need.
However, I'm looking for something that's more than merely an HTTP parser. Ideally it would开发者_运维百科 also take care of things such as session/connection management, multiplexing, etc... only that it would leave the actual implementation of the communication details for application to perform. I'm looking at both client and server ends, though any of them would be helpful.
Preferably I'm looking for something that's free (non GPLed, though). HTTPS is a plus. Lightweightness is a plus. Simplicity is a big plus.
Anything like this?
I think the best thing you are going to find is one that implements it in a well separated manner. An HTML Server without a socket implementation is useless to most of the world. I would look for well separated code. Here is an example of a very minimalistic html server that seems it may be well separated, not completely sure, as I have not tried it myself, but you could replace the socket classes with your own implementation and wrappers, and do it that way.
http://www.adp-gmbh.ch/win/misc/webserver.html
There may be other examples out there as well. A good google search may be your friend here. At any rate, I don't think you are going to find a totally disconnected server and client that is totally abstracted from the socket implementation(s) that they use. I've had to do this myself before, to write an html client that did not use sockets, but used serial io to another device, that would pass the data through onto the wider internet.
The problem is that once you want it to do session management, it's a LOT simpler to write the library to include the transport (usually sockets) handling directly, rather than try to define a usable interface that the application can implement to do the underlying transport work. Especially since most (obviously not all) users need both components anyway.
If you want a subset of a web-server read the source-code of an open-source server and strip out what you don't need. You might want to look at lighttpd and nginx. They are simple lightweight web-servers.
libsoup seems to do what you described. neon is close.
- session/connection management
- libsoup:
soup_session_sync_new()
- neon:
ne_session_create()
- libsoup:
- multiplexing
- I'm not sure what exactly you mean. whould you mind to enlighten me?
- leave the actual implementation of the communication details for application to perform.
- libsoup:
soup_message_headers_foreach()
andsoup_message_body_flatten()
- neon: no public API (would be nice to have
build_request()
as public)
- libsoup:
- both client and server ends
- libsoup: client and server API
- neon: client only
- free (non GPLed, though)
- libsoup: LGPL
- neon: GPL
- HTTPS
- libsoup: yes
- neon: yes
- Lightweightness is a plus
- it depends
- Simplicity is a big plus.
- it depends
精彩评论