response_creator.cc 1021 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this
  5. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
  6. #include <http/response_creator.h>
  7. namespace isc {
  8. namespace http {
  9. HttpResponsePtr
  10. HttpResponseCreator::createHttpResponse(const ConstHttpRequestPtr& request) {
  11. // This should never happen. This method must only be called with a
  12. // non null request, so we consider it unlikely internal server error.
  13. if (!request) {
  14. isc_throw(HttpResponseError, "internal server error: HTTP request is null");
  15. }
  16. // If not finalized, the request parsing failed. Generate HTTP 400.
  17. if (!request->isFinalized()) {
  18. return (createStockBadRequest(request));
  19. }
  20. // Message has been successfully parsed. Create implementation specific
  21. // response to this request.
  22. return (createDynamicHttpResponse(request));
  23. }
  24. }
  25. }