1 /** 2 * Copyright 2021 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MINDSPORE_CCSRC_PS_CORE_COMMUNICATOR_HTTP_MSG_HANDLER_H_ 18 #define MINDSPORE_CCSRC_PS_CORE_COMMUNICATOR_HTTP_MSG_HANDLER_H_ 19 20 #include <memory> 21 #include "ps/core/communicator/http_message_handler.h" 22 #include "ps/core/communicator/message_handler.h" 23 24 namespace mindspore { 25 namespace ps { 26 namespace core { 27 constexpr int kHttpSuccess = 200; 28 class HttpMsgHandler : public MessageHandler { 29 public: 30 explicit HttpMsgHandler(const std::shared_ptr<HttpMessageHandler> &http_msg); 31 ~HttpMsgHandler() override = default; 32 33 void *data() const override; 34 size_t len() const override; 35 bool SendResponse(const void *data, const size_t &len) override; 36 37 private: 38 std::shared_ptr<HttpMessageHandler> http_msg_; 39 unsigned char *data_; 40 size_t len_; 41 }; 42 } // namespace core 43 } // namespace ps 44 } // namespace mindspore 45 #endif // MINDSPORE_CCSRC_PS_CORE_COMMUNICATOR_HTTP_MSG_HANDLER_H_ 46