Skip to main content

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

Status Codes

Prism includes all standard HTTP status codes:
Common Status Codes
Custom 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’s Accept header:
Content Negotiation
Clients requesting 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.