---
name: "http_setUserAgent"
section: "3"
platform: "linux"
package: "libhttpfetcher-dev"
version: "1.0.1-3"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/http_setUserAgent"
---

# http\_setUserAgent(3)

Changes the User Agent shown to the server during an HTTP GET request.

## NAME

**http\_setUserAgent** - Changes the User Agent shown to the server during an HTTP GET request.

## SYNOPSIS

**#include \<http\_fetcher.h\>**\

**int http\_setUserAgent(const char \****newAgent***);**\

## DESCRIPTION

**The User Agent field of an HTTP request tells the server what software is making the request.  By default, "HTTP Fetcher/VERSION" is sent.**

**Calling http\_setUserAgent** will change the default User Agent to *newAgent* for subsequent requests (until the next call to **http\_setUserAgent**).

If you pass in **NULL** as an argument, HTTP Fetcher will NOT give the server a User Agent.

This function is useful for mimicing a browser, deceiving the webserver, or a number of other creative uses.

## RETURN VALUE

On success, **http\_setUserAgent** returns 0.

On error, -1 is returned, and the previous value of\
 *userAgent* is unchanged.  **http\_perror** can be used to print an informative error message.  **http\_strerror** can be used to get a pointer to the current error description message.

## SEE ALSO

[**http\_fetch**(3)](/http_fetch/3.md), [**http\_setReferer**(3)](/http_setReferer/3.md), [**http\_setTimeout**(3)](/http_setTimeout/3.md), [**http\_parseFilename**(3)](/http_parseFilename/3.md), [**http\_perror**(3)](/http_perror/3.md), [**http\_strerror**(3)](/http_strerror/3.md)
