---
name: "pmhttpNewClient"
section: "3"
platform: "linux"
package: "pcp"
version: "7.2.2-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/pmhttpNewClient"
---

# pmhttpNewClient(3)

simple HTTP client interfaces

## NAME

**pmhttpNewClient**, **pmhttpFreeClient**, **pmhttpClientFetch** - simple HTTP client interfaces

## C SYNOPSIS

**#include \<pcp/pmapi.h\>**\
 **#include \<pcp/pmhttp.h\>**

**struct http\_client \*pmhttpNewClient(void);**\
 **void pmhttpFreeClient(struct http\_client \****client***);**\
 **int pmhttpClientFetch(struct http\_client \****client***,** **const char \****url***,** **char \****bodybuf***,** **size\_t** *bodylen***,** **char \****typebuf***,** **size\_t** *typelen***);**

**cc ... -lpcp\_web**

## DESCRIPTION

**pmhttpNewClient** allocates and initializes an opaque HTTP client that is ready to make requests from a server.

The URL request interface **pmhttpClientFetch** issues an HTTP GET request to the server specified in the supplied *url*. The body of the response is returned in the caller supplied *bodybuf* buffer, of *bodylen* bytes length. An optional *typebuf* buffer, of *typelen* bytes length, can also be supplied and (if non-NULL) will contain the value of the content-type header returned from the server.

The *url* parameter is an *RFC1630* format URL. This will typically be prefixed with "http://", however these interfaces also support Unix domain sockets. Those are instead prefixed by "unix://", followed by the full filesystem path to the desired Unix domain socket.

To free up resources associated with an HTTP client, including closing any persistent server connection that has been established earlier, is accomplished using the **pmhttpFreeClient** routine.

## DIAGNOSTICS

**pmhttpNewClient** will return NULL on failure, which can only occur when allocation of memory is not possible.

**pmhttpClientFetch** will return the number of bytes places into the *bodybuf* buffer, else a negated error code indicating the nature of the failure.

## SEE ALSO

[**pmdaapache**(1)](/pmdaapache/1.md), [**pmjsonInit**(3)](/pmjsonInit/3.md), [**PMAPI**(3)](/PMAPI/3.md), [**PMWEBAPI**(3)](/PMWEBAPI/3.md) and **https://tools.ietf.org/html/rfc1630**.
