curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to send absolute URI?

From: Patrick Monnerat <patrick_at_monnerat.net>
Date: Tue, 21 Feb 2017 15:07:00 +0100

On 02/21/2017 02:50 PM, Tanyaofeng wrote:
> 1.I use curl-library 7.51 on Windows 7.
> 2.And I callcurl_easy_setopt(curl,CURLOPT_URL,“http://www.w3.org/pub/WWW/TheProject.html%e2%80%9d%ef%bc%89;
> expect to send a HTTP request like this:
> get http://www.w3.org/pub/WWW/TheProject.html HTTP / 1.1
> <http://www.w3.org/pub/WWW/TheProject.html%20HTTP%20/%201.1>
> 3.But I got request like this:
> get /pub/WWW/TheProject.html HTTP / 1.1
> host:www.w3.org
>
> How can I send an absolute URI HTTP request?
>
>
This is an absolute URI and this is the standard http protocol:
- The scheme is used to determine the protocol, and eventually the port.
- The given host is translated into an IP address and connected to.
- http protocol transmits the host allowing the server to resolve a
possible virtual hosting.
- the path in the "get" request starts with a "/" and thus is absolute.
- A full URI (scheme:://authority/path) in the request line would be
valid only with a "connect" request and requires the server to act as a
proxy, which is not what you expect.

Thus the absolute URI request is perfectly OK :-)

Patrick
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-02-21