of_svg ?status ?version ?reason ?headers ?env ?indent payload
creates a new response from the given values and a SVG body.
The content type of the response will be set to image/svg+xml
and the body will contain the SVG payload payload
.
The header Connection
will be set to Keep-Alive
to opimize for bandwitdh, since it is assumed that users who response SVG content will be likely to make further responses.
Example
The response initialized with:
let my_svg =
let open Tyxml.Svg in
svg
[ circle
~a:
[ a_cx (50., None)
; a_cy (50., None)
; a_r (40., None)
; a_fill (`Color ("black", None))
]
[]
]
;;
let res = Response.of_svg ~indent:true my_svg
res
will be represented as:
HTTP/1.1 200
Connection: Keep-Alive
Content-Type: image/svg+xml
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<circle cx="50" cy="50" r="40" fill="black"></circle>
</svg>