I'm working on a project in which I need to implement http from scratch; I have to put files together from packets rather than using a pre-built file grabber like wget or cURL. Are there any simple frameworks (cross platform or unix) for working with packets? Anyone have any examples of GET or PUT methods they've implemented themselves at the packet level?
-
Why do you need to implement it from scratch? Licensing issues? – Dennis Nov 28 '11 at 16:54
-
3You're mixing different network layers. HTTP has no concept of packets, and the TCP layer has no concept of HTTP. – Marc B Nov 28 '11 at 16:55
3 Answers
HTTP isn't implemented at the packet level, it's implemented on top of a TCP socket, which presents itself as a stream.
HTTP/1.1 is defined by RFC2616, although there are plenty of implementation tricks and traps that aren't obvious from the specification.

- 1
- 1

- 273,490
- 39
- 460
- 699
The points about the OSI layers everyone else is making aside...
You can serialize trivially with standard C++, or you can use archive/ASIO and similar mechanisms from the BOOST libraries.
Rather than point you to one place, I'd' suggest you read this question and its various answers through on stack overflow:
Serialize and send a data structure using Boost?
It covers your options pretty well and gives good resources to give you a happy grounding so you can make a more informed decision based on what you'll be doing.

- 1
- 1

- 37,047
- 37
- 155
- 255
-
HTTP request and response headers are linebreak-separated ASCII text. There's no need for serializing data structures. So the parts of that linked question that are useful here are just the parts that read/write byte data between a socket and a buffer. – Steve Jessop Nov 28 '11 at 17:06
You should try and use POCO HttpClient/HttpServer class from http://pocoproject.org/ HttpClient should support POST/GET methods that you need for client side.

- 4,465
- 4
- 42
- 69