#!/bin/bash
export LC_ALL=C
U=https://opencode.ai/zen/v1/chat/completions
B='{"model":"mimo-v2.6-flash-free","messages":[{"role":"user","content":"hi"}],"stream":true}'

echo "=== HTTP/1.1 + exact headers ==="
curl -sS --http1.1 -o /tmp/b -w '  HTTP %{http_code}  %{time_total}s\n' --max-time 40 -X POST "$U" \
  -H 'Content-Type: application/json' -H 'Accept: text/event-stream' \
  -H 'x-opencode-client: desktop' -H 'User-Agent: opencode/1.18.31' -d "$B" 2>&1 | head -2
printf '  '; head -c 240 /tmp/b | tr -d '\n'; echo

echo
echo "=== HTTP/1.1 through proxy ==="
curl -sS --http1.1 -o /tmp/b -w '  HTTP %{http_code}  %{time_total}s\n' --max-time 40 \
  -x http://172.19.0.1:20808 -X POST "$U" \
  -H 'Content-Type: application/json' -H 'Accept: text/event-stream' \
  -H 'x-opencode-client: desktop' -H 'User-Agent: opencode/1.18.31' -d "$B" 2>&1 | head -2
printf '  '; head -c 240 /tmp/b | tr -d '\n'; echo

echo
echo "=== HTTP/1.1, no UA override (curl default) ==="
curl -sS --http1.1 -o /tmp/b -w '  HTTP %{http_code}  %{time_total}s\n' --max-time 40 -X POST "$U" \
  -H 'Content-Type: application/json' -H 'Accept: text/event-stream' -d "$B" 2>&1 | head -2
printf '  '; head -c 200 /tmp/b | tr -d '\n'; echo
