login about faq

Hello,

It is my second topic with the same title, in previous topic problem was with cookies, but in this topic I want ask about rnt in headers. Why your library divide headers to new lines? You told that it is not problem, but I found some servers where I can't get responses.

Simple request. Without rnt in header Content-Type, good response:

---- Sending ----
POST /pings_do.xml HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: blogs.yandex.ru
Content-Length: 53

url=http%3A%2F%2F
---- Received ----
HTTP/1.1 302 Found

And with rnt in header, response is failed:

---- Sending ----
POST /pings_do.xml HTTP/1.1
Host: blogs.yandex.ru
Content-Length: 53
Content-Type: application/x-www-form-urlencoded;
     charset="Windows-1251"

url=http%3A%2F%2F
---- Not Connected ----

Can you make option for don't set new line in header?

asked Sep 09 '12 at 20:09

ozheek's gravatar image

ozheek
1334


Please show me the code snippet that uses Chilkat to produce the above HTTP request.

PS> HTTP requests and responses are MIME, and MIME is a fundamental building block of everything having to do with HTTP and email. There are some very basic characteristics of MIME that should be easily handled by any program supposedly capable of parsing and/or creating MIME. These characteristics include line continuation (folding/unfolding), encoding (quoted-printable and base64), case insensitivity of header fields, etc.

link

answered Sep 10 '12 at 12:24

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

I have worked with many libraries, and have never seen that headers in requests are sending with new lines. Maybe it is correct, but I have tested in several servers, and getting error if in headers are new lines. Maybe you can make option, that will turn off this for users, that don't need it?

    Chilkat.Http http = new Chilkat.Http();
    Chilkat.HttpRequest req = new Chilkat.HttpRequest();
    req.UsePost();
    req.Path = "/pings_do.xml";
    req.SendCharset = true;
    req.AddParam("url", "http://yandex.ru");

    var response = http.SynchronousRequest("blogs.yandex.ru", 80, false, req);
link

answered Sep 10 '12 at 19:39

ozheek's gravatar image

ozheek
1334

In this case, there is no need to send the "charset" attribute in the Content-Type header. If you set req.SendCharset = false, then your Content-Type header will not have the charset attribute and it won't use the continuation line.

link

answered Sep 10 '12 at 21:42

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Also, I tested your code, but found no problem. The use of continuation lines in the Content-Type header does not cause a failure:

---- Sending ----
POST /pings_do.xml HTTP/1.1
Host: blogs.yandex.ru
Content-Length: 28
Content-Type: application/x-www-form-urlencoded;
     charset="Windows-1251"

url=http%3A%2F%2Fyandex%2Eru
---- Received ----
HTTP/1.1 302 Found
Date: Tue, 11 Sep 2012 01:47:50 GMT
Content-Type: text/xml; charset=windows-1251
Cache-Control: max-age=0, must-revalidate, proxy-revalidate, no-cache, no-store, private
Expires: Tue, 11 Sep 2012 01:47:50 GMT
Location: /pings/?status=success&url=http%3A%2F%2Fyandex.ru
Set-Cookie: yandexuid=6405774661347328070; domain=.yandex.ru; path=/; expires=Tue, 19 Jan 2038 03:14:07 GMT
Connection: Close
Transfer-Encoding: chunked

10a
<?xml version="1.0" encoding="windows-1251"?>
<page xmlns:xi="http://www.w3.org/2001/XInclude" name="pings_do">

<state type="urlencode" name="url">http%3A%2F%2Fyandex.ru</state>

<text>Thanks for the ping.</text>

<lua/>

<lua/>

</page>

0

---- Sending ----
POST /pings/?status=success&url=http%3A%2F%2Fyandex.ru HTTP/1.1
Accept: */*
Accept-Encoding: gzip
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
User-Agent: Chilkat/1.0.0 (+http://www.chilkatsoft.com/ChilkatHttpUA.asp)
Host: blogs.yandex.ru
Connection: Keep-Alive

---- Received ----
HTTP/1.1 200 OK
Date: Tue, 11 Sep 2012 01:47:51 GMT
Content-Type: text/html; charset=UTF-8
Expires: Tue, 11 Sep 2012 01:52:51 GMT
Set-Cookie: yandexuid=3857380691347328071; domain=.yandex.ru; path=/; expires=Tue, 19 Jan 2038 03:14:07 GMT
Content-Encoding: gzip
Connection: Close
Transfer-Encoding: chunked

...
link

answered Sep 10 '12 at 21:50

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Very interesting, why I am getting error?

Please, try this code, I know that there is no reason for send character, but it is easy way to make header with new lines.

            Chilkat.Http http = new Chilkat.Http();
            Chilkat.HttpRequest req = new Chilkat.HttpRequest();
            req.UsePost();
            req.AddHeader("Accept", "text/html,application/xhtml+xml,application/xml; q=0.9,* /*; q=0.8");
            req.Path = "/pings_do.xml";
            req.AddParam("url", "http://yandex.ru");

            var response = http.SynchronousRequest("blogs.yandex.ru", 80, false, req);
link

answered Sep 11 '12 at 05:33

ozheek's gravatar image

ozheek
1334

Make sure you test with the very latest version of the Chilkat component (v9.3.2)

link

answered Sep 11 '12 at 08:17

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Yes, I am using the latest version (v.9.3.2). I don't have possibilities to check it in other computer, maybe you have some ideas what I can to do?

link

answered Sep 11 '12 at 13:00

ozheek's gravatar image

ozheek
1334

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:

×186

Asked: Sep 09 '12 at 20:09

Seen: 2,812 times

Last updated: Sep 11 '12 at 13:00

powered by OSQA