Skip to content

Fix Gemini 415 on FPC: valid Content-Type, drop invalid Content-Encoding: utf-8 - #187

Merged
FMXExpress merged 2 commits into
mainfrom
claude/gemini-content-type
Jun 8, 2026
Merged

FMXExpress merged 2 commits into
mainfrom
claude/gemini-content-type

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

Gemini POSTs fail with HTTP 415 on FPC builds

The FPC/Indy request path set:

Http.Request.ContentType    := 'application/json';
Http.Request.ContentEncoding := 'utf-8';   // ← invalid

Content-Encoding is only for transfer codings (gzip/deflate/br/identity) — utf-8 is not one. Anthropic and OpenAI ignore the bogus header, but Gemini strictly rejects the unknown content-coding with 415 Unsupported Media Type, so gemini/* chat POSTs (generateContent) fail:

assistant (gemini/gemini-3.5-flash):
gemini error: status=415 msg=HTTP/1.0 415 Unsupported Media Type

(The model-list GET has no body/Content-Type, which is why discovery worked but chat didn't.) The Delphi/TNetHTTPClient path already does this correctly (application/json; charset=utf-8, no Content-Encoding); only the FPC path was wrong.

Fix

All four Indy request sites (PostJSON, PutJSON, PostRaw, PostJSONToStream) now put the charset in Content-Type and drop Content-Encoding:

  • application/json; charset=utf-8
  • ContentType + '; charset=utf-8' for PostRaw

Notes

Verified

Clean rebuild under FPC 3.2.2, both default and C2W=1, no new warnings.

https://claude.ai/code/session_01LGQKz579j1ZnDRwmr6h1V6


Generated by Claude Code

claude added 2 commits June 8, 2026 21:49
…: utf-8' (FPC)

The FPC/Indy request path set Http.Request.ContentEncoding := 'utf-8',
emitting an invalid 'Content-Encoding: utf-8' header (Content-Encoding is
for gzip/deflate/br/identity, not a charset). Anthropic and OpenAI ignore
it, but Gemini's API strictly rejects the unknown content-coding with
HTTP 415 Unsupported Media Type — so gemini/* POSTs (generateContent)
failed on FPC builds, e.g. 'gemini error: status=415'.

Fix all four Indy request sites (PostJSON, PutJSON, PostRaw,
PostJSONToStream) to put the charset where it belongs —
'application/json; charset=utf-8' (and 'ContentType + ; charset=utf-8'
for PostRaw) — and stop setting Content-Encoding. This matches what the
Delphi/TNetHTTPClient path already does. Surfaced via the container2wasm
in-browser build, but affects native FPC + Gemini too.

Verified: clean rebuild (default and C2W=1), no new warnings.
The agent command only treats -m/--message as the prompt; a bare
positional ('pasclaw agent "hello"') is ignored and just starts an
interactive session. Correct the post-onboarding 'Next:' hint so the
one-shot example actually sends the message.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants