PHPackages                             guzzlehttp/message-integrity-subscriber - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. guzzlehttp/message-integrity-subscriber

AbandonedArchivedLibrary[HTTP &amp; Networking](/categories/http)

guzzlehttp/message-integrity-subscriber
=======================================

Verifies the integrity of HTTP responses using customizable validators (Guzzle 4+)

0.2.0(11y ago)1114.6k51MITPHPPHP &gt;=5.4.0

Since Mar 16Pushed 11y ago4 watchersCompare

[ Source](https://github.com/guzzle/message-integrity-subscriber)[ Packagist](https://packagist.org/packages/guzzlehttp/message-integrity-subscriber)[ Docs](http://guzzlephp.org/)[ RSS](/packages/guzzlehttp-message-integrity-subscriber/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (4)Used By (1)

Guzzle Message Integrity Subscriber
===================================

[](#guzzle-message-integrity-subscriber)

Verifies the integrity of HTTP responses using customizable validators.

This plugin can be used, for example, to validate the message integrity of responses based on the `Content-MD5` header. The plugin offers a convenience method for validating a `Content-MD5` header.

```
use GuzzleHttp\Client();
use GuzzleHttp\Subscriber\MessageIntegrity\ResponseIntegrity;

$subscriber = ResponseIntegrity::createForContentMd5();
$client = new Client();
$client->getEmitter()->attach($subscriber);
```

Installing
----------

[](#installing)

This project can be installed using Composer. Add the following to your composer.json:

```
{
    "require": {
        "guzzlehttp/message-integrity-subscriber": "0.2.*"
    }
}
```

Constructor Options
-------------------

[](#constructor-options)

The `GuzzleHttp\Subscriber\MessageIntegrity\ResponseIntegrity` class accepts an associative array of options:

expected(callable) A function that returns the hash that is expected for a response. The function accepts a ResponseInterface objects and returns a string that is compared against the calculated rolling hash.hash(`GuzzleHttp\Subscriber\MessageIntegrity\HashInterface`) A hash object used to compute a hash of the response body. The result created by the has is then compared against the extracted header value.size\_cutoff(integer) If specified, the message integrity will only be validated if the response size is less than the `size_cutoff` value (in bytes).```
use GuzzleHttp\Client();
use GuzzleHttp\Message\ResponseInterface;
use GuzzleHttp\Subscriber\MessageIntegrity\ResponseIntegrity;

$subscriber = new ResponseIntegrity([
    'hash' => new PhpHash('md5', ['base64' => true])
    'expected' => function (ResponseInterface $response) {
        return $response->getHeader('Content-MD5');
    }
]);

$client = new Client();
$client->getEmitter()->attach($subscriber);
```

Handling Errors
---------------

[](#handling-errors)

If the calculated hash of the response body does not match the extracted response's header, then a `GuzzleHttp\Subscriber\MessageIntegrity\MessageIntegrityException`is thrown. This exception extends from `GuzzleHttp\Exception\RequestException`so it contains a request accessed via `getRequest()` and a response via `getResponse()`.

```
use GuzzleHttp\Client();
use GuzzleHttp\Subscriber\MessageIntegrity\ResponseIntegrity;
use GuzzleHttp\Subscriber\MessageIntegrity\MessageIntegrityException;

$subscriber = ResponseIntegrity::createForContentMd5();
$client = new Client();
$client->getEmitter()->attach($subscriber);

try {
    $client->get('http://httpbin.org/get');
} catch (MessageIntegrityException $e) {
    echo $e->getRequest() . "\n";
    echo $e->getResponse() . "\n";
}
```

Limitations
-----------

[](#limitations)

- Only works with seekable responses or streaming responses.
- Does not currently work with responses that use a `Transfer-Encoding`header.
- Does not currently work with responses that use a `Content-Encoding` header.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~105 days

Total

3

Last Release

4227d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/190930?v=4)[Michael Dowling](/maintainers/mtdowling)[@mtdowling](https://github.com/mtdowling)

![](https://www.gravatar.com/avatar/0e4e105cea62b616d4cb376b08a849b6a428f646998537de150d16a8eb537b90?d=identicon)[mark.sagikazar](/maintainers/mark.sagikazar)

---

Top Contributors

[![mtdowling](https://avatars.githubusercontent.com/u/190930?v=4)](https://github.com/mtdowling "mtdowling (26 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (6 commits)")[![jeremeamia](https://avatars.githubusercontent.com/u/107867?v=4)](https://github.com/jeremeamia "jeremeamia (2 commits)")

---

Tags

httpGuzzle

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/guzzlehttp-message-integrity-subscriber/health.svg)

```
[![Health](https://phpackages.com/badges/guzzlehttp-message-integrity-subscriber/health.svg)](https://phpackages.com/packages/guzzlehttp-message-integrity-subscriber)
```

###  Alternatives

[kitetail/zttp

A developer-experience focused HTTP client, optimized for most common use cases.

1.7k1.2M72](/packages/kitetail-zttp)[kevinrob/guzzle-cache-middleware

A HTTP/1.1 Cache for Guzzle 6. It's a simple Middleware to be added in the HandlerStack. (RFC 7234)

43117.4M104](/packages/kevinrob-guzzle-cache-middleware)[php-http/guzzle7-adapter

Guzzle 7 HTTP Adapter

9057.1M555](/packages/php-http-guzzle7-adapter)[graham-campbell/guzzle-factory

Provides A Simple Guzzle Factory With Good Defaults

916.4M49](/packages/graham-campbell-guzzle-factory)[rtheunissen/guzzle-log-middleware

Guzzle middleware to log requests and responses

842.3M17](/packages/rtheunissen-guzzle-log-middleware)[graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

981.2M24](/packages/graze-guzzle-jsonrpc)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
