c多部分表单数据从服务器返回错误请求

I just made stackoverflow account because I'm having serious troubles sending multipart/form-data using my C application. There are many libraries I could use to send but for educational purposes I am doing it all from scratch so please bear with me.

The issue is that when I send the request using my application, the server happens to return 400 Bad Request. I saw this similar question here on stackoverflow and I am unable to fix the request nonetheless. Below is the request I have and a screenshot of what is returned from the server.

screenshot of program when run

// this is the temp_send which is incomplete
// adds the post data later
char *temp_send="POST http://localhost/france/test.php HTTP/1.1
"
                "Host: localhost
"
                "Accept: image/gif, image/jpeg, */*
"
                "Accept-Language: en-us
"
                "Content-Type: multipart/form-data; boundary=---------------------------7d41b838504d8
"
                "Accept-Encoding: gzip, deflate
"
                "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
"
                "Connection: keep-alive
"
                "Cache-Control: no-cache

"
                "---------------------------7d41b838504d8 Content-Disposition: form-data; name=\"name\"
"
                "%s
"
                "---------------------------7d41b838504d8--
";

char *postdata="testval";

char *sendbuf=NULL;
sendbuf=(char*)malloc(sizeof(char)*SENDLEN);
sprintf(sendbuf, temp_send, postdata);

NOTE: Somehow the "testval" is returned in the <pre> tags but I need the error to go away. I realize this is a broad question but I just need to narrow down the sending of multipart/form-data.

NOTE 2: I also know that I can use application/x-www-form-urlencoded and I have already used it and it works but since I will be doing file uploads which are much more complex, I need to use multipart-form/data and I'm trying with simple plain text first to reduce complexity

I finally got how to post simple data using multipart/post-data. I used fiddler and saw how the data is being passed. The content-length happened to be 238 and I've not tried with other data yet but setting the content-length to 238 or greater seemed to always work. This is the code now.

char *sendbuf="POST http://localhost/france/test.php HTTP/1.1
"
                        "Host: localhost
"
                        "Content-Length: 238
"   // content-length >=238
                        "Content-Type: multipart/form-data; boundary=----12345

"
                        "------12345
"
                        "Content-Disposition: form-data; name=\"name\"

"
                        "This is the first string
"
                        "------12345
"
                        "Content-Disposition: form-data; name=\"hell\"

"
                        "this is another string
"
                        "------12345
";

IMPORTANT: The Content-Length seems to be important when sending data and also the number of - are more after the boundary.ie. if boundary has k dashes then the following dashes seem to ALWAYS be k+2