LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-19-2014, 06:03 AM   #1
DiBosco
Member
 
Registered: Nov 2001
Location: Manchester, UK
Distribution: Mageia
Posts: 813

Rep: Reputation: 40
HTTP POST command to Apache server


I'm trying to get my embedded board to POST a file using HTTP to an Apache server running on my desktop.

I send this in the HTTP header:

Code:
    strcpy(pcBufferToTransmit,"POST /incoming/records.txt http/1.1\r\n");
    strcat(pcBufferToTransmit,"Host: 192.168.0.106\r\n");
    strcat(pcBufferToTransmit,"Connection: close\r\n");
    strcat(pcBufferToTransmit,"Content-Type: application/octet-stream\r\n");
    strcat(pcBufferToTransmit,"Content-Length: 20\r\n\r\n");
    FreeRTOS_send(xHTTPSocket,pcBufferToTransmit,MessageLength , 0 );
This is C code on theembedded server which concatenates those strings into one header string.

I then send a packet of twenty bytes, just 0-20. to send a dummy file.

The attached image shows how it comes out in Wireshark. It all gets bumdled up in to a single TCP packet and sent out. However, I get back an error 404, again, shown in a Wireshark JPEG attached.

I have given the incoming directory full permissions to be written to and. This "incoming" directory is in the same directory as index.html which I can get from the server with a GET command.

Is there anything anyone can think of that I am doing wrong? I don't really know anything about Apache setup and I am learning about using TCP/IP on embedded systems - so there are a lot of unknowns for me here.

I would stress that a GET cvommand pulls off index.html and sends it to me embedded board just fine, so the Apache server is working. At least in one direction.

If there is any other information that would help track this down, just ask!

Many thanks!
Attached Thumbnails
Click image for larger version

Name:	wireshark_post.jpeg
Views:	14
Size:	175.3 KB
ID:	16894   Click image for larger version

Name:	error_404.jpeg
Views:	18
Size:	224.8 KB
ID:	16895  
 
Old 11-19-2014, 07:24 AM   #2
DiBosco
Member
 
Registered: Nov 2001
Location: Manchester, UK
Distribution: Mageia
Posts: 813

Original Poster
Rep: Reputation: 40
Hmmm, as an update. If I actually put the file records.txt in the incoming/ directory, I get an HTTP/1.1 200 OK reply from the Apache server, but nothing gets written to that file on the hard drive.

I must be missing something pretty fundamental here!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] cURL POST data command from shell returns HTTP Error Code 408 fyndr Linux - Software 3 03-04-2011 09:17 AM
Apache HTTP Server gjagadish Programming 1 08-10-2006 09:10 AM
Apache HTTP Server gjagadish Linux - Software 2 02-09-2006 10:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration