| 688 | |
| 689 | |
| 690 | OK::OK(const JSON::Value& value, const Option<string>& jsonp) |
| 691 | : Response(Status::OK) |
| 692 | { |
| 693 | type = BODY; |
| 694 | |
| 695 | if (jsonp.isSome()) { |
| 696 | headers["Content-Type"] = "text/javascript"; |
| 697 | |
| 698 | string stringified = stringify(value); |
| 699 | |
| 700 | body.reserve(jsonp->size() + 1 + stringified.size() + 1); |
| 701 | body += jsonp.get(); |
| 702 | body += "("; |
| 703 | body += stringified; |
| 704 | body += ")"; |
| 705 | } else { |
| 706 | headers["Content-Type"] = "application/json"; |
| 707 | body = stringify(value); |
| 708 | } |
| 709 | |
| 710 | headers["Content-Length"] = stringify(body.size()); |
| 711 | } |
| 712 | |
| 713 | |
| 714 | OK::OK(JSON::Proxy&& value, const Option<string>& jsonp) |