Vinoth raj | 1 Dec 2011 11:18
Picon

HTTP post problem with quoted string as param

Dear Curl users,

I have problem in sending a parameter through HTTP post.
I want to send a parameter with double quotes (say "Quote 3").
I converted the string into UTF-8 as %e2%80%9cQuote%203%e2%80%9d and did a HTTP post to server.
When I receive the request parameter in servlet (using request.getParemeter) I get %C3%A2%C2%80%C2%9CQuote%203%C3%A2%C2%80%C2%9D
In servlet side I am using UTF-8 too. But what is not clear to me is how
%e2%80%9cQuote%203%e2%80%9d changed to %C3%A2%C2%80%C2%9CQuote%203%C3%A2%C2%80%C2%9D ( which on decoding gives junkQuotejunk)

Also, the curlopt errorbuffer did not report any error.
I don't want to send the parameter as %22Quote%203%22 but only as %e2%80%9cQuote%203%e2%80%9d

In short, I want send the encoded string %e2%80%9cQuote%203%e2%80%9d and receive at server end as such.

Or, can anyone suggest what is the correct way to send a quoted string as a parameter in http post?
Some code snippets would be useful.

Thanks,
Vinoth

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Chandran, Naveen | 1 Dec 2011 11:53
Picon
Favicon

issue with SMTP through HTTP proxy (using curl v 7.20.0)

Dear curl users,

 

I am trying to implement a minimal mailing mechanism using curl v7.20.0 and hence trying to connect to (and subsequently send mail) to an SMTP server through a HTTP proxy.

Therefore, among the options (to curl_easy_setopt), I am using:

·         CURLOPT_PROXY (to talk to a HTTP proxy) and

·         CURLOPT_HTTPPROXYTUNNEL (to tunnel through the proxy to reach the SMTP server)

 

Please note that with this setup:

·         The initial connection to the SMTP server is successful since the http CONNECT request sends back a "HTTP/1.1 200 Connection Established” header.

·         The SMTP server subsequently also identifies itself with a 220 <SMTP_server_name> ESMTP response

 

However, following this, there is an unwanted “GET / HTTP/1.1” header request to the SMTP server that gets sent
and hence the SMTP server at the other end terminates the connection with the following error messages:

 

500 Command unrecognized: "GET / HTTP/1.1"

500 Command unrecognized: "User-Agent: xxxxxxxxxxxxxxxxx"

500 Command unrecognized: "Host: xxxxxxxxxxxxxxxxxxxxxxx”

500 Command unrecognized: "GET / HTTP/1.1"

500 Command unrecognized: "User-Agent: xxxxxxxxxxxxxxxxx"

500 Command unrecognized: "Host: xx.xx.xx.xx"

500 Command unrecognized: "Accept: */*"

 

On the other hand, also please note that the mailing mechanism works perfectly fine if I turn the CURLOPT_PROXY option off.

 

Kindly let me know if I am missing anything here and if there is a way to talk SMTP via an HTTP proxy without the unwanted “GET /HTTP” header coming in the way of things.

Any help is greatly appreciated.

 

Thanks,

Naveen

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Daniel Stenberg | 1 Dec 2011 13:38
Picon
Favicon
Gravatar

Re: issue with SMTP through HTTP proxy (using curl v 7.20.0)

On Thu, 1 Dec 2011, Chandran, Naveen wrote:

> However, following this, there is an unwanted "GET / HTTP/1.1" header 
> request to the SMTP server that gets sent and hence the SMTP server at the 
> other end terminates the connection with the following error messages:

Are you sure you're using an SMTP:// URL?

--

-- 

  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Daniel Stenberg | 1 Dec 2011 13:42
Picon
Favicon
Gravatar

Re: issue with SMTP through HTTP proxy (using curl v 7.20.0)

On Thu, 1 Dec 2011, Chandran, Naveen wrote:

> Therefore, among the options (to curl_easy_setopt), I am using:

Oh and btw, libcurl questions are better taken to the proper mailing list: 
curl-library. This list is for users of the curl tool...

--

-- 

  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Alex Bligh | 1 Dec 2011 18:18
Picon

Saving the (public) certificate of a website to a file

I'm sure there is an easy way to do this, but a search of the manpage for
the word 'certificate' does not seem to bring it up.

How do I save the public certificate from a web page to a file?

Various browsers allow you to do this.

--

-- 
Alex Bligh

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Chandran, Naveen | 1 Dec 2011 18:40
Picon
Favicon

RE: issue with SMTP through HTTP proxy (using curl v 7.20.0)

Oh yes Daniel. I did specify the protocol to be smtp for the CURLOPT_URL part.
The SMTP server even presents itself with a "220 <server_name> ESMTP" message. 
But afterwards, I get the erroneous behavior nevertheless.

-----Original Message-----
From: curl-users-bounces <at> cool.haxx.se [mailto:curl-users-bounces <at> cool.haxx.se] On Behalf Of
Daniel Stenberg
Sent: Thursday, December 01, 2011 6:09 PM
To: the curl tool
Subject: Re: issue with SMTP through HTTP proxy (using curl v 7.20.0)

On Thu, 1 Dec 2011, Chandran, Naveen wrote:

> However, following this, there is an unwanted "GET / HTTP/1.1" header 
> request to the SMTP server that gets sent and hence the SMTP server at the 
> other end terminates the connection with the following error messages:

Are you sure you're using an SMTP:// URL?

--

-- 

  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Ralph Mitchell | 1 Dec 2011 18:52
Picon

Re: Saving the (public) certificate of a website to a file

On Thu, Dec 1, 2011 at 12:18 PM, Alex Bligh <alex <at> alex.org.uk> wrote:
I'm sure there is an easy way to do this, but a search of the manpage for
the word 'certificate' does not seem to bring it up.

How do I save the public certificate from a web page to a file?

Various browsers allow you to do this.

Here's one way to pick up a server cert:

     openssl s_client -connect server.domain.com:443 > server.pem < /dev/null

You'll probably want to edit the server.pem file to remove surplus bits on either side of the BEGIN & END CERTIFICATE lines.

Ralph Mitchell

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Alex Bligh | 1 Dec 2011 19:00
Picon

Re: Saving the (public) certificate of a website to a file

Ralph,

>      openssl s_client -connect server.domain.com:443 > server.pem <
> /dev/null

thanks. For future list readers:

openssl s_client -connect www.google.com:443 </dev/null 2>/dev/null | \
 sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'

--

-- 
Alex Bligh

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Dan Fandrich | 2 Dec 2011 10:39
Favicon

Re: HTTP post problem with quoted string as param

On Thu, Dec 01, 2011 at 03:48:08PM +0530, Vinoth raj wrote:
> I have problem in sending a parameter through HTTP post.
> I want to send a parameter with double quotes (say "Quote 3").
> I converted the string into UTF-8 as %e2%80%9cQuote%203%e2%80%9d and did a HTTP
> post to server.
> When I receive the request parameter in servlet (using request.getParemeter) I
> get %C3%A2%C2%80%C2%9CQuote%203%C3%A2%C2%80%C2%9D
> In servlet side I am using UTF-8 too. But what is not clear to me is how
> %e2%80%9cQuote%203%e2%80%9d changed to
> %C3%A2%C2%80%C2%9CQuote%203%C3%A2%C2%80%C2%9D ( which on decoding gives
> junkQuotejunk)

It turns out that if you treat the first string (%e2%80%9cQ...) as ISO-8859-1
and convert that to UTF-8, you get the second string (%C3%A2%C2%80%C2%9C...).
So, something is already doing that UTF-8 conversion for you. See what happens
if you don't convert the original parameter.

> Also, the curlopt errorbuffer did not report any error.
> I don't want to send the parameter as %22Quote%203%22 but only as
> %e2%80%9cQuote%203%e2%80%9d

The error buffer will only show an error if an error occurred. In this case,
curl happily sends the parameter and the server clearly has no issue (at
the HTTP level, anyway) in receiving it.

> In short, I want send the encoded string %e2%80%9cQuote%203%e2%80%9d and
> receive at server end as such.

It's likely the server doing that UTF-8 conversion for you. Perhaps you need
to specify a different charset=utf-8 parameter in the Content-Type header to
stop the server from converting the paramater again.

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Vinoth raj | 2 Dec 2011 11:38
Picon

Re: HTTP post problem with quoted string as param

The point "treat %e2%80%9cQuote%203%e2%80%9d" as ISO-8859-1 is not clear to me.
On converting "Quote 3" to UTF-8 in my C++ app I get the encoded string as %e2%80%9cQuote%203%e2%80%9d
So, %e2%80%9cQuote%203%e2%80%9d is basically UTF-8.
Now I am posting this UTF-8 encoded string to server through HTTP post.
On the server (Apache Tomcat) side I had tried setting the content-type to ISO-8859-1 but received junkQuotejunk.
UTF-8 as content-type also yielded same.

So, when sending the UTF-8 encoded string should I set any encoding type in C++ using curl.
Also, what encoding type should I set on server side?

I tried this:

C++ side
Curl post parameter: mystring=%e2%80%9cQuote%203%e2%80%9d

Servlet side
request.setContentType("text/html", charset=ISO-8859-1);
Now, request.getParameter("mystring") yielded %C3%A2%C2%80%C2%9CQuote%203%C3%A2%C2%80%C2%9D
Tried, URIDecoder.decode(request.getParameter("mystring"), "ISO-8859-1") yielded junkQuotejunk

In short, what encoding type should I set at C++ side using CURL and also at server side?

Kindly help!

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Gmane