login about faq

I need to send raw post data (not structured as param1->value&param2->value and so on). So I use the following code:

Chilkat.Http http = new Chilkat.Http();
        http.UnlockComponent("My code");
        Chilkat.HttpRequest request = new Chilkat.HttpRequest();
        Chilkat.HttpResponse response = null;

        http.SessionLogFilename = "C:\\Users\\kolchakA\\Documents\\SessionLogFilename.txt";
        http.VerboseLogging = true;

        http.SaveCookies = true;
        http.SendCookies = true;

        string rawDataToPOST = "rawdata_so_simple";

        response = http.PostMime("http://synoparser.ru/clientsite/cookdir/", rawDataToPOST);

=========

But I get null responce. Below I provide SessionLogFilename.txt

=======SessionLogFilename.txt=======

---- Sending ---- POST /clientsite/cookdir/ HTTP/1.1 rawdata_so_simple

======

asked Dec 02 '12 at 03:10

datacol's gravatar image

datacol
1666


You first need to become familiar with the most basic concepts of HTTP. All HTTP requests and responses are MIME messages. You just can't throw garbage at the server and expect a valid response. If you're sending a POST, then it must include a Content-Length header indicating the exact length of the MIME body. Calling SendMime assumes you are a little familiar with HTTP and MIME. If not, I would highly recommend the O'Reilly book "HTTP: The Definitive Guide".

HTTP requests and responses have the same format. They are composed of a "start line" followed by MIME. (For simplicity, I'm omitting the possibility of chunked responses.)

The "start line" of an HTTP request is a line such as:

GET /test/something.html HTTP/1.0

It has 3 parts: the HTTP method (GET, POST, PUT, etc.), the resource URI, and the HTTP protocol version. Following the start line is the MIME header, followed by the MIME body.

A server would consume an incoming HTTP request by reading the incoming data on the TCP socket (or possibly SSL/TLS connection) in the following way:

  1. Consume the start line by reading until the first CRLF.
  2. Consume the HTTP request header by reading until the first double CRLF.
  3. If the HTTP request is GET, HEAD, or possibly some others, then the MIME body is assumed to be empty, and you are done. Perhaps the next HTTP request might be arriving on the same connection..
  4. If a MIME body is to follow (and the MIME body might actually be a multi-part MIME message with nested multi-part MIME messages), then the total size of the entire MIME body is indicated in the "Content-Length" header field. The server should read this exact number of bytes to consume the full MIME body. The MIME body may include binary data, so it's best to read this into a byte array -- NOT a string.
  5. Now that the server has both MIME header and body, compose the full MIME message in a byte array (the header followed by body) and then use the Chilkat MIME API to access the content of the MIME (you can get header fields, body content, navigate to MIME sub-parts, etc.)
  6. The server's response would be a start line followed by MIME.
link

answered Dec 03 '12 at 18:54

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

can I send raw POST data (not structured as param1->value&param2->value and so on) in some other way (without being little familiar with HTTP and MIME)?

link

answered Dec 04 '12 at 13:13

datacol's gravatar image

datacol
1666

can you provide me simple example of post mime usage?

link

answered Dec 06 '12 at 03:56

datacol's gravatar image

datacol
1666

Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

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

Tags:

×1

Asked: Dec 02 '12 at 03:10

Seen: 1,186 times

Last updated: Dec 06 '12 at 03:56

Related questions

powered by OSQA