Re: Http User-Agent



Arto Karppinen wrote:
> 
> Does libsoup 2.2 support setting User-Agent string? Because i found
> nothing in 2.2 documentation about it.

libsoup 2.2 is a little out of date now. 2.4 came out last spring, and
the current version is 2.24 (which, despite the massive version bump, is
really just a little bit more than 2.4).

In 2.2 there was no explicit support for User-Agent, but you can
manually set it on each request:

    msg = soup_message_new (...);
    soup_message_add_header (msg, "User-Agent", "whatever/1.0");
    ...

In 2.4, you can cause User-Agent to be appended to every message
automatically by setting the SOUP_SESSION_USER_AGENT property on the
session. Eg,

    session = soup_session_async_new_with_options (
            SOUP_SESSION_USER_AGENT, "whatever/1.0 ",
            NULL);

If the user agent string ends with a space, as in the example above,
libsoup will append its own version to the end, so you'd get something like:

    User-Agent: whatever/1.0 libsoup/2.24.0

If you don't want it to do that, just don't leave a space at the end of
the USER_AGENT property.

-- Dan


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]