BlogIntegrations · November 23, 2026 · 4 min read

Contact Form 7 Webhooks: Distinguish Request Compression from Response Negotiation

Match gzip request bytes to Content-Encoding, distinguish Accept-Encoding and keep decoded size limits and receiver outcomes explicit.

Folded mint paper passes through a narrowing green sleeve toward a small envelope.
Generated conceptual illustration.

A custom Contact Form 7 handoff may send JSON to a receiver that supports compressed request bodies. Adding Accept-Encoding: gzip does not compress that JSON. It describes acceptable response coding. If the sender advertises one representation and transmits another, the receiver can reject a perfectly ordinary inquiry before field mapping starts.

This guide separates the outgoing request from the incoming response. It applies to a custom connector whose receiving API explicitly supports request compression. It does not instruct you to modify CF7’s browser submission endpoint or assume that every CRM accepts compressed input.

Write down the receiver’s contract first

Confirm which endpoint accepts compressed requests, which coding it supports and where decoding happens. A reverse proxy may decode the body before application middleware sees it. Conversely, an application may receive the original compressed bytes. Document that boundary so two layers do not both try to decompress the same request.

Also confirm the accepted media type and both encoded and decoded size limits. Compression changes the representation on the wire; it does not make a large decoded inquiry acceptable to a receiver with a smaller application limit. Start with the uncompressed path if the receiver does not document support.

Give each header one job

Content-Encoding identifies coding applied to the current message body. For compressed JSON, Content-Type: application/json still describes the data after decoding, while Content-Encoding: gzip says how the transmitted bytes were coded. Setting the header without actually compressing the bytes creates a mismatch.

In an outgoing request, Accept-Encoding tells the server which response codings the client can handle. It does not authorize or perform request compression. Client libraries differ in their automatic response decompression, so verify that behavior before adding a second manual decoder.

HTTP semantics also distinguishes content coding from transfer framing. Do not use Transfer-Encoding as a substitute for a documented gzip request contract. Let the HTTP implementation calculate framing and lengths from the exact bytes it will send.

Serialize once, then compress the bytes

This offline Python example uses synthetic data. It creates an ordinary UTF-8 JSON representation, compresses it and verifies a local round trip. It makes no network call and does not establish that your receiver supports gzip.

import gzip
import json

payload = {"inquiry_id": "demo-23", "message": "Synthetic inquiry"}
raw = json.dumps(payload, ensure_ascii=False).encode("utf-8")
encoded = gzip.compress(raw, compresslevel=6, mtime=0)
headers = {
    "Content-Type": "application/json",
    "Content-Encoding": "gzip",
}
assert gzip.decompress(encoded) == raw
assert json.loads(gzip.decompress(encoded)) == payload

# A reviewed HTTP client would send encoded as its binary body.
# Passing payload to a JSON convenience argument would serialize again.

The gzip module accepts bytes for compression. The JSON module handles serialization separately. Preserve that order when adapting the example to a real client. Do not convert compressed bytes to a text string or place them inside a JSON field unless a different receiver protocol explicitly requires such an envelope.

Compare encoded and raw byte lengths during development rather than assuming every inquiry becomes smaller. Small messages may gain overhead. Record sizes and the chosen coding with operational identifiers, keeping private message contents out of general-purpose logs. Our UTF-8 payload size guide covers the earlier measurement boundary.

Keep content coding in the connector configuration, alongside the endpoint and payload version. If a receiver changes its supported codings, review that change before the next deployment. A proxy’s ability to compress downloaded pages does not establish that the same route accepts compressed POST bodies.

Handle signatures and decoding deliberately

If the integration signs requests, follow the receiving protocol’s exact definition of the signed bytes. Some schemes cover the transmitted representation; others define a different canonical input. Compressing after signing is only correct if that protocol says so. Keep a fixture for the precise order and verify at the receiver boundary.

At a receiver you operate, impose limits during decompression as well as before it. An unbounded convenience decompressor is suitable for this tiny trusted fixture, not a complete public upload handler. Bound decoded bytes, execution time and allowed codings, then apply JSON and field validation after successful decoding.

Test failure modes without creating real leads

Use an isolated receiver with a harmless fixture. Include correct gzip, plain JSON with a gzip header, gzip without its header, truncated bytes, an unsupported coding and a decoded body beyond the allowed size. Verify that failures stop before record creation and return a stable error that your connector can classify.

A server may use HTTP 415 for an unsupported media type or content coding. Diagnose the documented response instead of blindly retrying the same representation. After a timeout or uncertain response, reconcile by inquiry ID before resending. Compression does not provide idempotency, and a successful transport response does not by itself prove that downstream processing finished.

Keep the previous uncompressed path available only when it is part of the reviewed protocol and duplicate handling is defined. For form-level trends, the free Svetlik Analytics plugin has a separate documented scope. It is not a request-compression service or a guarantee that a CRM accepted the inquiry.