LCOV - code coverage report
Current view: top level - msus/webserver - regex_msu.c (source / functions) Hit Total Coverage
Test: unnamed Lines: 7 9 77.8 %
Date: 2018-01-11 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             : START OF LICENSE STUB
       3             :     DeDOS: Declarative Dispersion-Oriented Software
       4             :     Copyright (C) 2017 University of Pennsylvania, Georgetown University
       5             : 
       6             :     This program is free software: you can redistribute it and/or modify
       7             :     it under the terms of the GNU General Public License as published by
       8             :     the Free Software Foundation, either version 3 of the License, or
       9             :     (at your option) any later version.
      10             : 
      11             :     This program is distributed in the hope that it will be useful,
      12             :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :     GNU General Public License for more details.
      15             : 
      16             :     You should have received a copy of the GNU General Public License
      17             :     along with this program.  If not, see <http://www.gnu.org/licenses/>.
      18             : END OF LICENSE STUB
      19             : */
      20             : #include "local_msu.h"
      21             : #include "msu_type.h"
      22             : #include "msu_message.h"
      23             : #include "msu_calls.h"
      24             : #include "logging.h"
      25             : #include "routing_strategies.h"
      26             : 
      27             : #include "webserver/write_msu.h"
      28             : #include "webserver/regex_msu.h"
      29             : #include "webserver/connection-handler.h"
      30             : #include "webserver/httpops.h"
      31             : 
      32           2 : static int craft_ws_regex_response(struct local_msu *self,
      33             :                                    struct msu_msg *msg) {
      34           2 :     struct response_state *resp = msg->data;
      35             : 
      36           2 :     if (!has_regex(resp->url)) {
      37           0 :         log_error("Regex MSU received request without regex");
      38           0 :         return -1;
      39             :     }
      40             : 
      41           2 :     resp->body_len = craft_regex_response(resp->url, resp->body);
      42           2 :     resp->header_len = generate_header(resp->header, 200, MAX_HEADER_LEN,
      43             :                                        resp->body_len, "text/html");
      44           2 :     call_msu_type(self, &WEBSERVER_WRITE_MSU_TYPE, &msg->hdr, sizeof(*resp), resp);
      45           2 :     return 0;
      46             : }
      47             : 
      48             : struct msu_type WEBSERVER_REGEX_MSU_TYPE = {
      49             :     .name = "Webserver_regex_msu",
      50             :     .id = WEBSERVER_REGEX_MSU_TYPE_ID,
      51             :     .receive = craft_ws_regex_response,
      52             :     .route = shortest_queue_route
      53             : };

Generated by: LCOV version 1.10