| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
bad-server is an http server that can be told to respond in various bad ways. It is primarily intended for testing clients to make sure they're resilient to server outages.
bad-server figures out what behavior to exhibit based on headers you send it. In general, the first header will win if you have multiple instances of the same header in a request. Exceptions to this include:
X-Response-Code-Histogram: send a status code based on an input histogram
X-Request-Body-As-Response: send the request body back in the response
X-Pause-Before-Response-Start: wait the specified amount of time before sending a response.
X-Add-Noise: randomly mutate bytes based on randomness percentage
X-Return-Header: set the given header to the given value. Multiple instances of this header will get collated
X-Generate-Random: generate random data for the given number of bytes
X-Random-Delays: randomly delay sending chunks of data
X-Proxy-To-Host: send the exact same request to the specified host and feed the response to the client. Note that other header and request generators will be ignored if this is set. However, headers that affect the transmission will still be used.
X-Random-Json: send random but structured JSON to the client to simulate unexpectedly large payloads
Here are the primitive data types you can use for a field:
Each of these can have [] placed around them to create an array of that type. Primitive types (string, int, float) can have an enum of appropriate values. Arrays are 10,000 items unless you specify a length with ":N" after the array. The "root" item must be identified with "response_template="
Combining headers lets you create other types of unexpected behaviors.
Response's content-type does not match content.
X-Return-Header: Content-Type: application/json X-Generate-Random: 600
Response's Content-Length is longer than content.
X-Return-Header: Content-Length: 6000 X-Generate-Random: 1000
Response's Content-Length is shorter than content.
X-Return-Header: Content-Length: 1000 X-Generate-Random: 6000
The server also has an admin port that you can use for certain global operations
bad-server works by creating an ordered pipeline of functions that all take http.ResponseWriter pointers. Functions are placed into the pipeline in this order:
Only one status code generator and response body generator will be derived from the headers sent to bad-server. If you include multiple response body generators in your header, they will be processed in this order (from general.go)
1. X-Request-Body-As-Response 2. X-Generate-Random 3. X-Random-Json 4. empty string
| Back | FazBrowse Home | New Git URL |