LCOV - code coverage report
Current view: top level - root/contrail/src/contrail-common/http - http_request.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 8 12 66.7 %
Date: 2026-08-03 02:19:58 Functions: 4 6 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #ifndef __HTTP_REQUEST_H__
       6             : #define __HTTP_REQUEST_H__
       7             : 
       8             : #include <map>
       9             : #include <string>
      10             : 
      11             : #include "io/tcp_session.h"
      12             : #include "http_parser/http_parser.h"
      13             : 
      14             : class HttpRequest {
      15             : public:
      16             :     typedef std::map<std::string, std::string> HeaderMap;
      17             : 
      18             :     HttpRequest();
      19             : 
      20          10 :     void SetMethod(http_method method) { method_ = method; }
      21             :     http_method GetMethod() const { return method_; }
      22             :     // clobbers argument
      23          20 :     void SetUrl(std::string *url) {
      24          20 :         url_.swap(*url);
      25          20 :     }
      26          50 :     void PushHeader(const std::string &key, const std::string &value) {
      27          50 :         headers_.insert(make_pair(key, value));
      28          50 :     }
      29           0 :     void SetBody(const char *data, size_t length) {
      30           0 :         body_.append(data, length);
      31           0 :     }
      32          10 :     void SetEvent(enum TcpSession::Event event) { event_ = event; }
      33             : 
      34             :     std::string ToString() const;
      35             : 
      36             :     std::string UrlPath() const;
      37             :     std::string UrlQuery() const;
      38             :     const HeaderMap & Headers() const { return headers_; }
      39             :     const std::string & Body() const { return body_; }
      40           0 :     TcpSession::Event Event() const { return event_; }
      41             : private:
      42             :     http_method method_;
      43             :     std::string url_;
      44             :     HeaderMap headers_;
      45             :     std::string body_;
      46             :     TcpSession::Event event_; // used when the request indicates an event
      47             : };
      48             : 
      49             : #endif

Generated by: LCOV version 1.14