http-parser-lite 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -253,9 +253,9 @@ enum state
253
253
  , s_req_schema
254
254
  , s_req_schema_slash
255
255
  , s_req_schema_slash_slash
256
- , s_req_host_start
257
- , s_req_host
258
- , s_req_host_with_at
256
+ , s_req_server_start
257
+ , s_req_server
258
+ , s_req_server_with_at
259
259
  , s_req_path
260
260
  , s_req_query_string_start
261
261
  , s_req_query_string
@@ -465,19 +465,19 @@ parse_url_char(enum state s, const char ch)
465
465
 
466
466
  case s_req_schema_slash_slash:
467
467
  if (ch == '/') {
468
- return s_req_host_start;
468
+ return s_req_server_start;
469
469
  }
470
470
 
471
471
  break;
472
472
 
473
- case s_req_host_with_at:
473
+ case s_req_server_with_at:
474
474
  if (ch == '@') {
475
475
  return s_dead;
476
476
  }
477
477
 
478
478
  /* FALLTHROUGH */
479
- case s_req_host_start:
480
- case s_req_host:
479
+ case s_req_server_start:
480
+ case s_req_server:
481
481
  if (ch == '/') {
482
482
  return s_req_path;
483
483
  }
@@ -486,12 +486,12 @@ parse_url_char(enum state s, const char ch)
486
486
  return s_req_query_string_start;
487
487
  }
488
488
 
489
- if (IS_USERINFO_CHAR(ch) || ch == '[' || ch == ']') {
490
- return s_req_host;
489
+ if (ch == '@') {
490
+ return s_req_server_with_at;
491
491
  }
492
492
 
493
- if (ch == '@') {
494
- return s_req_host_with_at;
493
+ if (IS_USERINFO_CHAR(ch) || ch == '[' || ch == ']') {
494
+ return s_req_server;
495
495
  }
496
496
 
497
497
  break;
@@ -613,9 +613,9 @@ size_t http_parser_execute (http_parser *parser,
613
613
  case s_req_schema:
614
614
  case s_req_schema_slash:
615
615
  case s_req_schema_slash_slash:
616
- case s_req_host_start:
617
- case s_req_host:
618
- case s_req_host_with_at:
616
+ case s_req_server_start:
617
+ case s_req_server:
618
+ case s_req_server_with_at:
619
619
  case s_req_query_string_start:
620
620
  case s_req_query_string:
621
621
  case s_req_fragment_start:
@@ -976,7 +976,7 @@ size_t http_parser_execute (http_parser *parser,
976
976
 
977
977
  MARK(url);
978
978
  if (parser->method == HTTP_CONNECT) {
979
- parser->state = s_req_host_start;
979
+ parser->state = s_req_server_start;
980
980
  }
981
981
 
982
982
  parser->state = parse_url_char((enum state)parser->state, ch);
@@ -991,7 +991,7 @@ size_t http_parser_execute (http_parser *parser,
991
991
  case s_req_schema:
992
992
  case s_req_schema_slash:
993
993
  case s_req_schema_slash_slash:
994
- case s_req_host_start:
994
+ case s_req_server_start:
995
995
  {
996
996
  switch (ch) {
997
997
  /* No whitespace allowed here */
@@ -1011,8 +1011,8 @@ size_t http_parser_execute (http_parser *parser,
1011
1011
  break;
1012
1012
  }
1013
1013
 
1014
- case s_req_host:
1015
- case s_req_host_with_at:
1014
+ case s_req_server:
1015
+ case s_req_server_with_at:
1016
1016
  case s_req_path:
1017
1017
  case s_req_query_string_start:
1018
1018
  case s_req_query_string:
@@ -1999,14 +1999,14 @@ http_parse_host(const char * buf, struct http_parser_url *u, int found_at) {
1999
1999
  if (s != s_http_host) {
2000
2000
  u->field_data[UF_HOST].off = p - buf;
2001
2001
  }
2002
- u->field_data[UF_HOST].len ++;
2002
+ u->field_data[UF_HOST].len++;
2003
2003
  break;
2004
2004
 
2005
2005
  case s_http_host_v6:
2006
2006
  if (s != s_http_host_v6) {
2007
2007
  u->field_data[UF_HOST].off = p - buf;
2008
2008
  }
2009
- u->field_data[UF_HOST].len ++;
2009
+ u->field_data[UF_HOST].len++;
2010
2010
  break;
2011
2011
 
2012
2012
  case s_http_host_port:
@@ -2015,7 +2015,7 @@ http_parse_host(const char * buf, struct http_parser_url *u, int found_at) {
2015
2015
  u->field_data[UF_PORT].len = 0;
2016
2016
  u->field_set |= (1 << UF_PORT);
2017
2017
  }
2018
- u->field_data[UF_PORT].len ++;
2018
+ u->field_data[UF_PORT].len++;
2019
2019
  break;
2020
2020
 
2021
2021
  case s_http_userinfo:
@@ -2024,7 +2024,7 @@ http_parse_host(const char * buf, struct http_parser_url *u, int found_at) {
2024
2024
  u->field_data[UF_USERINFO].len = 0;
2025
2025
  u->field_set |= (1 << UF_USERINFO);
2026
2026
  }
2027
- u->field_data[UF_USERINFO].len ++;
2027
+ u->field_data[UF_USERINFO].len++;
2028
2028
  break;
2029
2029
 
2030
2030
  default:
@@ -2059,7 +2059,7 @@ http_parser_parse_url(const char *buf, size_t buflen, int is_connect,
2059
2059
  int found_at = 0;
2060
2060
 
2061
2061
  u->port = u->field_set = 0;
2062
- s = is_connect ? s_req_host_start : s_req_spaces_before_url;
2062
+ s = is_connect ? s_req_server_start : s_req_spaces_before_url;
2063
2063
  uf = old_uf = UF_MAX;
2064
2064
 
2065
2065
  for (p = buf; p < buf + buflen; p++) {
@@ -2073,7 +2073,7 @@ http_parser_parse_url(const char *buf, size_t buflen, int is_connect,
2073
2073
  /* Skip delimeters */
2074
2074
  case s_req_schema_slash:
2075
2075
  case s_req_schema_slash_slash:
2076
- case s_req_host_start:
2076
+ case s_req_server_start:
2077
2077
  case s_req_query_string_start:
2078
2078
  case s_req_fragment_start:
2079
2079
  continue;
@@ -2082,11 +2082,11 @@ http_parser_parse_url(const char *buf, size_t buflen, int is_connect,
2082
2082
  uf = UF_SCHEMA;
2083
2083
  break;
2084
2084
 
2085
- case s_req_host_with_at:
2085
+ case s_req_server_with_at:
2086
2086
  found_at = 1;
2087
2087
 
2088
2088
  /* FALLTROUGH */
2089
- case s_req_host:
2089
+ case s_req_server:
2090
2090
  uf = UF_HOST;
2091
2091
  break;
2092
2092
 
@@ -2121,6 +2121,7 @@ http_parser_parse_url(const char *buf, size_t buflen, int is_connect,
2121
2121
  }
2122
2122
 
2123
2123
  /* host must be present if there is a schema */
2124
+ /* parsing http:///toto will fail */
2124
2125
  if ((u->field_set & ((1 << UF_SCHEMA) | (1 << UF_HOST))) != 0) {
2125
2126
  if (http_parse_host(buf, u, found_at) != 0) {
2126
2127
  return 1;
@@ -29,6 +29,7 @@ extern "C" {
29
29
 
30
30
  #include <sys/types.h>
31
31
  #if defined(_WIN32) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER<1600)
32
+ #include <BaseTsd.h>
32
33
  typedef __int8 int8_t;
33
34
  typedef unsigned __int8 uint8_t;
34
35
  typedef __int16 int16_t;
@@ -37,9 +38,8 @@ typedef __int32 int32_t;
37
38
  typedef unsigned __int32 uint32_t;
38
39
  typedef __int64 int64_t;
39
40
  typedef unsigned __int64 uint64_t;
40
-
41
- typedef unsigned int size_t;
42
- typedef int ssize_t;
41
+ typedef SIZE_T size_t;
42
+ typedef SSIZE_T ssize_t;
43
43
  #else
44
44
  #include <stdint.h>
45
45
  #endif
@@ -289,7 +289,7 @@ size_t http_parser_execute(http_parser *parser,
289
289
 
290
290
 
291
291
  /* If http_should_keep_alive() in the on_headers_complete or
292
- * on_message_complete callback returns true, then this will be should be
292
+ * on_message_complete callback returns true, then this should be
293
293
  * the last message on the connection.
294
294
  * If you are the server, respond with the "Connection: close" header.
295
295
  * If you are the client, close the connection.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-parser-lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-21 00:00:00.000000000 Z
12
+ date: 2012-07-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake