tags:

views:

38

answers:

1

I have a multipart header, which starts with

------------------123456\r\n

where 123456 is a guid. I want to extract this out. I'm trying to find in the specifications how this header is made, but I don't know why there are so many dashes or even if the number of them is fixed. w3c seems to suggest there are only two dashes --123456 but obviously that's not correct as you can see.

What's the best way to parse the ID out so I can use it to split the other headers up?

Edit: I'm not getting a boundary, my incoming data looks like this. My form contains a textbox and a file upload:

    -----------------------------7da292321290902\r\nContent-Disposition: form-data;
 name=\"my_title\"\r\n\r\nWhat I typed in the textbox\r\n-----------------------------
7da292321290902\r\nContent-Disposition: form-data; name=\"upload\";
 filename=\"C:\\myFile.zip\"\r\nContent-Type: application/x-zip-compressed\r\n\r\n ascii
 data here for the file contents
+2  A: 

The boundary should be specified in the Content-Type: part of your MIME document.

Content-Type: multipart/mixed; 
              boundary=----------------123456

You should then be able to search for the lines

"--"+boundary+"\r\n"

and

"--"+boundary+"--\r\n"

There are various RFCs specifying the MIME format, but Wikipedia gives a good overview: http://en.wikipedia.org/wiki/MIME

relet
Another part of the program stripped this out and stored it which is why I was so confused, but I found it and it's all good now. Thanks very much!
SLC