Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#1749 closed defect (fixed)

WMS client does not set user-agent

Reported by: bartvde@… Owned by: dmorissette
Priority: high Milestone:
Component: WMS Client Version: 4.8
Severity: normal Keywords:
Cc:

Description

According to:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html, section 14.43 User-Agent
the user-agent *should* be set.

Hi list,

the WMS client code of Mapserver does not set the User-Agent in the http
headers, and we have encountered some Apache webservers which throw an
internal server error when there is no User-Agent set. We have successfully
patched our maphttp.c with the change below and this seems to work. Would it
be a good idea to apply this patch (or a similar patch) in Mapserver's
source code?

        /* set URL, note that curl keeps only a ref to our string buffer */
        curl_easy_setopt(http_handle, CURLOPT_URL, pasReqInfo[i].pszGetUrl
);

        // patch
        char szBuf[100];

        struct curl_slist *headers=NULL;
        snprintf(szBuf, 100, "User-Agent: curl");
        headers = curl_slist_append(headers, szBuf);
        curl_easy_setopt(http_handle, CURLOPT_HTTPHEADER, headers);
        // end patch 

Best regards,
Bart

Change History (4)

comment:1 by dmorissette, 18 years ago

Cc: mapserver-bugs@… added
Owner: changed from mapserverbugs to dmorissette
Looking at our WMS demo server logs, it seems that MapServer is not the only WMS
client to not set the User-Agent. It is probably a good idea to fix this in
MapServer, but I think it's the web server should be fixed to not throw an error.

Anyway, back to MapServer, I propose that we set this via the CURLOPT_USERAGENT
option instead of CURLOPT_HTTPHEADER.

Also, the HTTP 1.1 header fields RFC says that "The field can contain multiple
product tokens (section 3.8) and comments identifying the agent and any
subproducts which form a significant part of the user agent. By convention, the
product tokens are listed in order of their significance for identifying the
application."
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43

So I propose that the value be set to something like:

  User-Agent: MapServer/4.8.x Curl/7.11.x

(Assuming I can easily get the version info from MapServer and Curl.)

Looking into this now.

comment:2 by dmorissette, 18 years ago

Status: newassigned

comment:3 by dmorissette, 18 years ago

Resolution: fixed
Status: assignedclosed
Fixed in 4.9 in CVS.

The User-Agent string reported by Apache on my test server looks like this:
"MapServer/4.9 libcurl/7.15.0"

Since the fix is more than a one-liner and involved adding new members to the
httpRequestObj struct (to track and free the ref to the user-agent string), I
would rather not backport to 4.98 unless really necessary.

Actually, if backporting to 4.8 is required, I would likely use a static string
hardcoded to "MapServer/4.8" which would be safer to implement for a stable release.

comment:4 by bartvde@…, 18 years ago

Hi Daniel,

thanks for the quick action!

Bart
Note: See TracTickets for help on using tickets.