Response
PrismHTTPResponse represents what your server sends back to the client. Prism provides convenient factory methods for common response types, plus full control when you need it.
Quick Response Factories
- JSON
- Text
- HTML
- Redirect
Status Codes
Prism includes all standard HTTP status codes:Common Status Codes
Custom Headers
Custom Headers
Building Responses Manually
For full control, construct a response from scratch:Manual Response
Body Types
PrismHTTPBody supports several formats:
Body Types
Streaming Responses
For large files or real-time data, use chunked transfer encoding:Chunked Response
Content Negotiation
Respond with different formats based on the client’sAccept header:
Content Negotiation
Accept: application/xml get XML. Those requesting Accept: text/csv get CSV. JSON is the default fallback.
Practical Patterns
API Response Envelope
Consistent API Responses
File Downloads
File Download
Streaming
Stream large responses with chunked encoding.
Content Negotiation
Serve multiple formats from a single endpoint.