Revision e11386c0 event_http/event_http_server.c

View differences:

event_http/event_http_server.c
15 15
#include <http_default_urls.h>
16 16
#include "chunk_external_interface.h"
17 17

  
18
int ulEventHttpServerSetup(const char *address, unsigned short port, data_processor_function data_processor) {
18
static char input_http_path[255];
19

  
20
int ulEventHttpServerSetup(const char *address, unsigned short port, const char* path, data_processor_function data_processor) {
19 21
  struct evhttp* evh = NULL;
20
  debug("Setting up event-based http server listening at %s:%d", address, port);
22
  debug("Setting up event-based http server listening at %s:%d on path: %s", address, port, path);
21 23

  
22 24
  evh = evhttp_new(eventbase);
23 25

  
24 26
  if(evh != NULL) {
25
    info("Event-based http server at %s:%d has been setup", address, port);
26
    fprintf(stderr, "Event-based http server at %s:%d has been setup\n", address, port);
27
    info("Event-based http server at %s:%d on path: %s has been setup", address, port, path);
27 28
  }
28 29
  else {
29
    error("Setup of event-based http server at %s:%d FAILED", address, port);
30
    error("Setup of event-based http server at %s:%d on path: %s FAILED", address, port, path);
30 31
    return UL_RETURN_FAIL;
31 32
  }
32 33

  
......
42 43
  //function and also pass to it a pointer to an external data_processor function, which is
43 44
  //able to handle the received data specifically
44 45
  evhttp_set_gencb(evh, ulEventHttpServerProcessRequest, data_processor);
46

  
47
  sprintf(input_http_path, "/%s", path);
48
  debug("Setting up static path to: %s", input_http_path);
49

  
45 50
  return UL_RETURN_OK;
46 51
}
47 52

  
......
63 68
    if(!strncmp(path, UL_HTTP_PREFIX , strlen(UL_HTTP_PREFIX))) {  //if it begins by "http://"
64 69
      path = strchr(path + strlen(UL_HTTP_PREFIX),'/'); //skip "http://host:port" part
65 70
    }
66
    debug("HTTP POST request is for path %s", path);
71
    debug("HTTP POST request is for path %s, and should be for %s\n", path, input_http_path);
67 72

  
68
    if(!strcmp(path, UL_DEFAULT_CHUNKBUFFER_PATH)) {
73
    if(!strcmp(path, input_http_path)) {
69 74
      //give back the data
70 75
      //should i copy it in order to "free" the req pointer??
71 76
      //no, because the data processr makes a copy

Also available in: Unified diff