login about faq

Hey guys.

Could you tell me how to make a http multipart request with Chilkat?

Wireshark shows me that I have to send the following header:

Content-Type: multipart/form-data; boundary=---------------------------26204304919913

but I can not set ContentType to this string value, because Chilkat cuts the real content type at ";"

So this code is not working:

                Chilkat.HttpRequest req = new Chilkat.HttpRequest();
                req.HttpVerb = WebRequestMethods.Http.Post;
                req.AddHeader("Content-Type", "multipart/form-data; boundary=---------------------------"+ boundary);

AddHeader or set ContentType are both not working.

How can I solve the problem?


asked Apr 18 '13 at 17:05

BlackMatrix's gravatar image


HTTP requests and responses are MIME. Understanding MIME is key to understanding that it makes no difference that the boundary string is continued on the next line. MIME headers may be split into several lines. A line that begins with a SPACE or TAB character is a continuation of the current header field. Therefore, the following two lines are completely equivalent:

Content-Type: multipart/form-data; boundary=---------------------------26204304919913

is 100% equivalent to

Content-Type: multipart/form-data; 

Also, there is no need to explicitly specify a boundary string because it will automatically be generated based on the fact that the Content-Type is "multipart/form-data". Therefore, the only thing you should need to do is to set the ContentType property equal to "multipart/form-data".


answered Apr 18 '13 at 21:01

chilkat's gravatar image

chilkat ♦♦


And how do I add parameters then? With the normal HttpWebRequest I did the following to create my poststring:

        var postStringBuilder = new StringBuilder();
        postStringBuilder.AppendLine("-----------------------------" + boundary);
        postStringBuilder.AppendLine("Content-Disposition: form-data; name=\"step\"");

So with Chilkat I only have to this?

        Chilkat.HttpRequest req = new Chilkat.HttpRequest();
        req.HttpVerb = WebRequestMethods.Http.Post;

Edit: Yes, its working.


answered Apr 19 '13 at 09:43

BlackMatrix's gravatar image


edited Apr 19 '13 at 09:49

Corret. With Chilkat you do not have to build the raw MIME of the request. Instead, you specify what is desired, such as extra header names/values, or request parameter names/values, and the HTTP class/component builds the MIME when sending the request.

(Apr 19 '13 at 10:08) chilkat ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Apr 18 '13 at 17:05

Seen: 2,742 times

Last updated: Apr 19 '13 at 10:08

powered by OSQA