I am implementing a client and server in C (on linux) and i want to send a text file to a server from the client using an HTTP PUT message.
I'm not really sure how to do this. Do I first send the HTTP request and header line over the socket, and then send the file over the socket piece by piece using a buffer? or do I need to prepend every piece of the text file with its own HTTP request and header line before I send them over?
I also read about this function called sendfile that seems like it would make this easier, but I wasn't sure how I would prepend an HTTP header and request line to the file if sendfile just sends the file straight to the socket.
Thank you for your help.