--- parser3/src/main/pa_http.C 2020/10/10 06:08:36 1.84 +++ parser3/src/main/pa_http.C 2020/10/11 23:25:10 1.86 @@ -14,7 +14,7 @@ #include "pa_vfile.h" #include "pa_random.h" -volatile const char * IDENT_PA_HTTP_C="$Id: pa_http.C,v 1.84 2020/10/10 06:08:36 moko Exp $" IDENT_PA_HTTP_H; +volatile const char * IDENT_PA_HTTP_C="$Id: pa_http.C,v 1.86 2020/10/11 23:25:10 moko Exp $" IDENT_PA_HTTP_H; #ifdef _MSC_VER #include @@ -48,7 +48,7 @@ volatile const char * IDENT_PA_HTTP_C="$ // helpers -bool ResponseHeaders::add_header(const char *line){ +bool HTTP_Headers::add_header(const char *line){ const char *value=strchr(line, ':'); if(value && value != line){ // we need only headers, not the response code @@ -103,7 +103,7 @@ public: size_t buf_size; size_t body_offset; - ResponseHeaders headers; + HTTP_Headers headers; const String &url; HTTP_response(const String& aurl) : buf(NULL), length(0), buf_size(0), body_offset(0), url(aurl){} @@ -884,8 +884,8 @@ File_read_http_result pa_internal_file_r if (!real_remote_charset) real_remote_charset=asked_remote_charset; // never null - for(Array_iterator i(response.headers.headers); i.has_next(); ){ - ResponseHeaders::Header header=i.next(); + for(Array_iterator i(response.headers.headers); i.has_next(); ){ + HTTP_Headers::Header header=i.next(); header.transcode(*real_remote_charset, r.charsets.source()); @@ -991,7 +991,7 @@ void HTTPD_request::read_header(int sock /* ********************************************************** */ -Array &HTTPD_Connection::headers() { +Array &HTTPD_Connection::headers() { return request->headers.headers; } @@ -1018,10 +1018,19 @@ void HTTPD_Connection::read_header(){ static int sock_on = 1; -int HTTPD_Server::bind(const char *host, int port){ +int HTTPD_Server::bind(const char *host_port){ struct sockaddr_in me; - if(!set_addr(&me, host, port)){ + const char *port = strchr(host_port, ':'); + const char *host = NULL; + if(port && port > host_port){ + host = pa_strdup(host_port, port - host_port); + port += 1; + } else { + port = host_port; + } + + if(!set_addr(&me, host, pa_atoui(port, 10))){ if (host) throw Exception("httpd.bind", 0, "can not resolve hostname \"%s\"", host); me.sin_addr.s_addr=INADDR_ANY;