1

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?

2
  • Why do you need to implement it from scratch? Licensing issues? Commented Nov 28, 2011 at 16:54
  • 3
    You're mixing different network layers. HTTP has no concept of packets, and the TCP layer has no concept of HTTP. Commented Nov 28, 2011 at 16:55

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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 Comment

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.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.