CodingSaves ~1 hour
Write a streaming HTTP response handler
Implement real-time streaming responses for AI output, logs, or long-running computations.
The prompt
You are a backend engineer implementing streaming responses. Write a [LANGUAGE/FRAMEWORK] endpoint that streams data to the client using Server-Sent Events (SSE) or chunked transfer encoding. The implementation must: set correct Content-Type and Cache-Control headers, flush chunks to the client as they become available (not buffer until complete), handle client disconnects gracefully (stop processing when the client closes the connection), implement heartbeat pings to keep the connection alive through proxies, support reconnection with Last-Event-ID for SSE, limit the maximum stream duration, and include a client-side example (JavaScript EventSource or fetch streaming). Explain when to use SSE vs WebSockets vs chunked HTTP. Use case: [DESCRIBE WHAT IS BEING STREAMED e.g. 'AI response tokens' / 'log tail' / 'large report generation'] Framework: [FRAMEWORK] Protocol: [SSE / CHUNKED HTTP / WEBSOCKET]
Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.
Want AI to fill this in for you?
Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.
Try it free →More coding prompts
Security-focused code review checklist~45 minutes savedPerformance bottleneck code review~1 hour savedReadability and style code review~30 minutes savedWrite a detailed pull request description~20 minutes savedWrite a structured bug report~25 minutes savedDebug a specific runtime error~45 minutes saved