Gateway behaviour and limits
The gateway receives every request at a project’s address and answers it. This page lists its limits, the paths it keeps for itself, the headers it changes and the answers it gives without a mock; How MockHub handles a request explains the order of its checks.
Limits
Section titled “Limits”In the Value column, a name in bold is a plan limit, as the limits page names it; Plans, quotas and limits explains how plan limits work. Every plan limit is shared by all projects in the workspace. The other values are the same on every plan.
| Limit | Value | When it is exceeded |
|---|---|---|
| Request body | Traffic request body limit | 413 |
| Response body, from a mock or upstream | Traffic response body limit | 502 |
| Requests in flight at once | Concurrent requests per workspace | The request waits up to a second for one to finish, then 429, Retry-After: 1 |
| Requests per second | Requests per second per workspace, with bursts up to Burst capacity per workspace | 429, Retry-After: 1 |
| Requests per hour, day and month | Requests an hour, Requests a day, Requests per month per workspace | 429, Retry-After in seconds until the limit resets |
| Time for a mock to answer | 70 seconds, a simulated delay included | 502 |
| Simulated delay on a mock | Maximum simulated delay (ms) | The delay is shortened to the maximum |
| Streamed response | Longest streamed response (ms) | Played faster to fit; on a plan without it, sent in one piece |
| Delayed answers waiting at once | Delayed responses held at once per workspace, with their bodies together up to 64 KiB for each, or one Traffic response body limit if that is more | Each further delayed answer counts as a request in flight for its whole delay |
| Time for an upstream to answer | 15 seconds in all, and at most 5 seconds without any data | 502 |
| Forwards to an upstream per day, month | The daily allowance under Record and proxy to a real API, and Upstream forwards per month per workspace | The request is answered as in Mock only, without an error |
| Body kept in a request log | Captured request body limit, Captured response body limit, and never more than 1 MiB | The kept copy is cut off and ends with [TRUNCATED: … bytes omitted] |
| Headers kept in a request log | 64 KiB for the request’s, 64 KiB for the response’s | The rest are left out, and x-mockhub-log-headers-truncated: true is kept in their place |
| Limit | Value | When it is exceeded |
|---|---|---|
| Forwards to an upstream at once | 3 per workspace, shared with webhook deliveries, alerts and AI generation | 429, Retry-After: 1; nothing is forwarded or recorded |
| Limit | Value | When it is exceeded |
|---|---|---|
| Request headers | 16 KiB in all, a little more over HTTP/1.1 | 431, or the connection is closed without an answer |
The caller receives the whole response even when the request log keeps a shortened copy.
Reserved paths
Section titled “Reserved paths”No mock can answer on these paths, whatever it matches:
/__adminand everything under it: an empty404./__inboxand everything under it, with any method: the webhook inbox, which answers200./__tls-ask: an empty404.
Answers the gateway gives itself
Section titled “Answers the gateway gives itself”None of the answers down to the 429s counts against the workspace’s limits.
| Status | Body | When | Logged |
|---|---|---|---|
404 |
Empty | The path is /__admin or under it |
No |
404 |
Project not found |
No project has this hostname, or its custom domain is no longer verified | No |
308 |
Empty; Location is the same address over HTTPS |
Plain HTTP to a domain that serves HTTPS only | No |
421 |
Problem JSON, This domain serves HTTP only. |
HTTPS to a domain that serves HTTP only | No |
402 |
JSON; see the bodies | The workspace is suspended over a payment, or awaits its first one | No |
410 |
JSON; see the bodies | The demo the project belongs to has ended | No |
403 |
JSON; see the bodies | The project is archived, or beyond the number of projects the plan lets answer | No |
413 |
See the bodies | The request body is over the plan’s limit | No |
400 |
Problem JSON, A multipart request needs a boundary parameter in its Content-Type, such as multipart/form-data; boundary=x. |
A multipart/* request without a boundary in its Content-Type |
No |
429 |
Problem JSON, Workspace request allowance exceeded. Retry after the indicated reset. |
A per-second, hourly, daily or monthly limit is reached | No |
200 |
{"received":true} |
The path is /__inbox or under it |
When Store request logs is on |
404 |
Problem JSON, No mock matched: No active mock in this project matches GET /nope., naming the method and path without the query |
No mock matched, and nothing forwarded the request | When Log requests no mock answered is on |
502 |
Mock did not answer |
The mock did not answer in time, or an active chaos profile injected a fault | Yes |
502 |
Upstream connection failed |
An active chaos profile injected a fault in place of forwarding the request | Yes |
502 |
Problem JSON, Mock response exceeded the plan traffic body limit. |
The mock’s response is over the plan’s limit | No |
500 |
Failed to prepare the project's mocks |
MockHub could not load the project’s mocks | Yes |
503 |
Service temporarily unavailable |
MockHub has no server available to run the project’s mocks | Yes |
A private project checks its access before the 402 and everything below it. A request over plain HTTP, failing the project’s access policy, or from an address that recently sent repeated refused requests gets 404 Project not found, the same answer as an unknown hostname, and is neither logged nor counted. Project keys use X-MockHub-Key. A private project is never redirected to HTTPS. A CORS preflight is answered without a key.
Ahead of the 402, a workspace taken down for breaking the Terms of Service answers every request to its projects:
| Status | Body | When | Logged |
|---|---|---|---|
410 |
JSON; see the bodies | The workspace’s content was removed under the Terms of Service | No |
| Status | Body | When | Logged |
|---|---|---|---|
429 |
Problem JSON, Concurrent request capacity is full. Retry shortly. |
Too many requests still in flight a second after this one arrived, for the workspace or for MockHub as a whole, or a forward while the workspace has three outgoing requests under way | No |
| Status | Body | When | Logged |
|---|---|---|---|
502 |
Text starting Upstream unreachable:, Upstream refused: or Upstream request failed:, or Upstream response exceeded the … byte limit. |
Forwarding to the upstream failed | Yes, as a capture |
A browser’s preflight is answered before any check that could refuse it, unless the project’s CORS is Off, or it has an active OPTIONS mock and is not in Record everything:
| Status | Body | When | Logged |
|---|---|---|---|
204 |
Empty | An OPTIONS request with Origin and Access-Control-Request-Method headers |
No |
The 502 that a running chaos profile’s connection fault causes, Mock did not answer or Upstream connection failed, is logged with chaos: fault, shown as Connection cut. The gateway cannot tell a cut from a mock that did not answer, so every such 502 on a path the profile covers is logged that way while the profile runs. Answers a chaos profile injected or delayed are logged with chaos: error or chaos: latency. None of them counts in insights or alert rules; see Read request logs.
A redirect a mock or an upstream sends is passed to the caller; the gateway follows none. Hostnames, domains and protocols explains the schemes a domain serves, and Gateway modes how forwarding works.
Refusal bodies
Section titled “Refusal bodies”These refusals are problem JSON, sent as application/problem+json:
| Status | Problem type | detail |
|---|---|---|
402 |
Workspace suspended | Complete this workspace subscription to start serving requests. while the workspace awaits its first payment, otherwise This workspace is suspended. Open Subscription settings for the reason and next steps. Your definitions are preserved. |
410 |
Demo expired | This demo has ended. Claim it to keep your work. |
403 |
Plan limit | This project is archived or exceeds the active project allowance. Your definitions are preserved. Choose active projects or upgrade. |
413 |
Plan limit | Request body exceeds the traffic limit. |
429 |
Plan limit | The workspace upstream request allowance is exhausted. Wait for the daily or monthly reset, or upgrade. when a request needs forwarding to the upstream in Proxy unmatched or Record everything |
| Status | Problem type | detail |
|---|---|---|
410 |
Content removed | This content was removed for violating the MockHub Terms of Service. |
A request that sends X-MockHub-Response can also be refused:
| Status | Problem type | detail |
|---|---|---|
400 |
Response selector malformed | The X-MockHub-Response header must hold one value of the form <mock reference>:<response key>, as the mock's editor copies it. |
422 |
Response selection unavailable | The response named in X-MockHub-Response cannot be served for this request. Check that its mock is active, matches the request and allows request overrides. |
Neither is a hit of any mock, and neither is forwarded to an upstream, in any gateway mode.
An archived project, for example:
{ "type": "https://mockhub.dev/problems/plan-limit", "title": "Plan limit reached", "status": 403, "detail": "This project is archived or exceeds the active project allowance. Your definitions are preserved. Choose active projects or upgrade."}The two 429 bodies carry the Plan limit problem type too:
{ "type": "https://mockhub.dev/problems/plan-limit", "title": "Plan limit reached", "status": 429, "detail": "Workspace request allowance exceeded. Retry after the indicated reset."}Request headers
Section titled “Request headers”Before a request is matched against mocks or forwarded to an upstream, the gateway removes these headers from it:
Accept-Encoding, Connection, Content-Length, Keep-Alive, Proxy-Authorization, Proxy-Connection, TE, Trailer, Transfer-Encoding, Upgrade, Via, X-Forwarded-For, X-Forwarded-Host, X-Forwarded-Proto
It also removes every header whose name contains . or _, such as api_key or X-User.Id, without an error. Send such a value under a name made of letters, digits and hyphens instead, such as Api-Key.
It replaces Host: mocks see a name of MockHub’s own, and an upstream sees its own hostname. Every other header, Authorization and Cookie included, reaches the mocks and the upstream as the caller sent it, and so does the query string, repeated parameters and their order included.
It also removes X-MockHub-Key, on every project, so no mock, upstream or request log sees an access key.
X-MockHub-Response: <mock reference>:<response key>, the mock reference being the last 12 characters of the mock’s identifier, asks the mock a request matched for one of its other responses for that request only; see Choose the response that answers. It takes no part in matching, and it is never sent to an upstream. Browser pages may send it when the project’s CORS allows their origin: the gateway’s preflight allows the headers the page asks for.
Response headers
Section titled “Response headers”| Header | What the gateway does |
|---|---|
Content-Type |
Sets text/html; charset=utf-8 when the response has none, and adds ; charset=utf-8 to a text/… type that has no charset |
Cache-Control |
Sets no-cache, private when the response has none, or private, must-revalidate when it has Expires or Last-Modified. Adds , private to a value that has none of public, private or s-maxage |
Strict-Transport-Security |
Removes it on a shared domain that also serves HTTP. Passes it on elsewhere, and never adds one |
Content-Encoding |
Removes it and passes the body on decoded. The response can then arrive compressed with zstd, Brotli or gzip when the caller’s Accept-Encoding allows it |
Date |
Adds it when the response has none |
Server, and hop-by-hop headers such as Connection, Keep-Alive, Transfer-Encoding, Via |
Removes them, and sets its own Content-Length |
- A mock cannot send
X-MockHub-Key: a mock or configuration document with it as a response header is refused, and the gateway removes it from every answer. - A mock cannot send the headers MockHub uses to say which response answered,
MockHub-Selected-ResponseandMockHub-Selection-Refused: a response with either is refused, and the gateway removes them from every answer. They appear nowhere a caller or the request log can read, except as the log’s own record of which response answered. - On a shared domain, the gateway adds
Content-Security-Policy: sandboxto every answer for a project, its308and421included, beside any policy the mock sends, and removes theDomainattribute of aSet-Cookiethat names anything but the project’s own hostname. It also addsX-Content-Type-Options: nosniff, and answers a browser that navigates to a download, an attachment or a type outside the short list a browser displays, with a403Download blocked, which lists the types; a request from code gets the file. On a custom domain it does none of this. Pages and cookies on a shared domain explains why. - A
204or304response is sent without a body orContent-Type, and the answer to aHEADrequest has no body. - The gateway reads the whole response before sending it on, so a caller receives nothing until the mock or upstream has finished. A mock’s stream is then sent in paced chunks; an upstream’s answer arrives whole.
- A mock cannot send
MockHub-Stream,MockHub-AiorX-MockHub-Stream, which MockHub reserves for a stream’s pacing and an AI model response: a response with one is refused, and the gateway removes them from every answer.
The project’s Browser access (CORS) setting decides which pages may read its answers; Let web pages call a project sets it. The gateway adds the headers only to a request that carries Origin, and to every answer after the domain checks, its own refusals included:
| Header | Any website, the default | Only these origins, a listed origin | Off or an unlisted origin |
|---|---|---|---|
Access-Control-Allow-Origin |
* |
The request’s Origin |
Not sent |
Access-Control-Allow-Credentials |
Not sent | true |
Not sent |
Access-Control-Expose-Headers |
The response’s own header names | The same | Not sent |
Vary |
Adds Origin, even without Origin |
The same | Unchanged with Off |
The exposed names leave out Set-Cookie and the headers a page can always read, such as Content-Type and Cache-Control.
A preflight is an OPTIONS request with Origin and Access-Control-Request-Method. Unless the project has an active mock whose method is OPTIONS and is not in Record everything, the gateway answers it with an empty 204 carrying the headers above for the request’s Origin, plus:
| Header | Value |
|---|---|
Access-Control-Allow-Methods |
The method in Access-Control-Request-Method |
Access-Control-Allow-Headers |
The headers in Access-Control-Request-Headers, when it has any |
Access-Control-Max-Age |
600 |
Vary |
Origin, Access-Control-Request-Method, Access-Control-Request-Headers |
With an active OPTIONS mock, preflights are matched against the mocks like any other request and count against the workspace’s limits; the gateway answers only the ones no mock matched, so none reaches the upstream. In Record everything no mock runs, and the gateway answers every preflight itself: none is forwarded or recorded. A mock with Any method does not answer a preflight unless it compares Access-Control-Request-Method itself. An OPTIONS mock’s answer without its own Access-Control-Allow-Origin gets the headers of both tables added, with the mock’s status.
The gateway changes nothing in a response that already has Access-Control-Allow-Origin, which is how a mock sets its own CORS. An upstream’s Access-Control-* headers are removed when the project forwards, and the project’s are added; the capture keeps the upstream’s. The request log shows a response without the headers the gateway added.
No CORS header lets a page served over HTTPS call an http:// address; see HTTP and browsers.