online / endpoints 62 / categories 10 / rate 60/min/ip /

GET /matched-content-type

GET /matched-content-type alias: /wrong-content-type

Returns a JSON body labelled application/json — the Content-Type matches the body. Counterpart to the chaos /wrong-content-type endpoint, which mismatches the two on purpose.

expect: 200 OK with Content-Type: application/json and a JSON body. The declared type matches the bytes.

bash
curl -i 'https://not.catastrophic.io/matched-content-type'
import urllib.request
resp = urllib.request.urlopen("https://not.catastrophic.io/matched-content-type")
print("Declared:", resp.headers.get("Content-Type"))
print("Actual:",   resp.headers.get("X-Chaos-Body-Format"))
print(resp.read().decode())
const res = await fetch("https://not.catastrophic.io/matched-content-type");
console.log("Content-Type:", res.headers.get("content-type"));
console.log(await res.text());
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    resp, _ := http.Get("https://not.catastrophic.io/matched-content-type")
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println("Content-Type:", resp.Header.Get("Content-Type"))
    fmt.Println(string(body))
}
// Cargo.toml: reqwest = { version = "0.12", features = ["blocking"] }
fn main() -> Result<(), Box> {
    let resp = reqwest::blocking::get("https://not.catastrophic.io/matched-content-type")?;
    println!("Content-Type: {:?}", resp.headers().get("content-type"));
    println!("{}", resp.text()?);
    Ok(())
}
import java.net.URI;
import java.net.http.*;

public class WrongContentType {
    public static void main(String[] args) throws Exception {
        var client = HttpClient.newHttpClient();
        var req = HttpRequest.newBuilder(URI.create("https://not.catastrophic.io/matched-content-type")).build();
        var resp = client.send(req, HttpResponse.BodyHandlers.ofString());
        System.out.println("Content-Type: " + resp.headers().firstValue("Content-Type").orElse(""));
        System.out.println(resp.body());
    }
}
using var client = new HttpClient();
var resp = await client.GetAsync("https://not.catastrophic.io/matched-content-type");
Console.WriteLine($"Content-Type: {resp.Content.Headers.ContentType}");
Console.WriteLine(await resp.Content.ReadAsStringAsync());
require "net/http"
res = Net::HTTP.get_response(URI("https://not.catastrophic.io/matched-content-type"))
puts "Content-Type: #{res["Content-Type"]}"
puts res.body
# Invoke-RestMethod respects Content-Type and will NOT auto-parse
# this as JSON despite the body being valid JSON.
$r = Invoke-WebRequest -Uri 'https://not.catastrophic.io/matched-content-type'
$r.Headers['Content-Type']
$r.Content