agoo 2.9.0 → 2.10.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of agoo might be problematic. Click here for more details.

@@ -44,12 +44,13 @@ json_size(const char *str, size_t len) {
44
44
 
45
45
  agooText
46
46
  agoo_text_create(const char *str, int len) {
47
- agooText t = (agooText)AGOO_MALLOC(sizeof(struct _agooText) - AGOO_TEXT_MIN_SIZE + len + 1);
47
+ size_t alen = (AGOO_TEXT_MIN_SIZE <= len) ? len : AGOO_TEXT_MIN_SIZE;
48
+ agooText t = (agooText)AGOO_MALLOC(sizeof(struct _agooText) + alen + 1);
48
49
 
49
50
  if (NULL != t) {
50
51
  t->next = NULL;
51
52
  t->len = len;
52
- t->alen = len;
53
+ t->alen = alen;
53
54
  t->bin = false;
54
55
  atomic_init(&t->ref_cnt, 0);
55
56
  memcpy(t->text, str, len);
@@ -77,12 +78,13 @@ agoo_text_dup(agooText t0) {
77
78
 
78
79
  agooText
79
80
  agoo_text_allocate(int len) {
80
- agooText t = (agooText)AGOO_MALLOC(sizeof(struct _agooText) - AGOO_TEXT_MIN_SIZE + len + 1);
81
+ size_t alen = (AGOO_TEXT_MIN_SIZE <= len) ? len : AGOO_TEXT_MIN_SIZE;
82
+ agooText t = (agooText)AGOO_MALLOC(sizeof(struct _agooText) + alen + 1);
81
83
 
82
84
  if (NULL != t) {
83
85
  t->next = NULL;
84
86
  t->len = 0;
85
- t->alen = len;
87
+ t->alen = alen;
86
88
  t->bin = false;
87
89
  atomic_init(&t->ref_cnt, 0);
88
90
  *t->text = '\0';
@@ -28,7 +28,7 @@ agooText
28
28
  agoo_ws_add_headers(agooReq req, agooText t) {
29
29
  int klen = 0;
30
30
  const char *key;
31
-
31
+
32
32
  t = agoo_text_append(t, up_con, sizeof(up_con) - 1);
33
33
  if (NULL != (key = agoo_con_header_value(req->header.start, req->header.len, "Sec-WebSocket-Key", &klen)) &&
34
34
  klen + sizeof(ws_magic) < MAX_KEY_LEN) {
@@ -84,7 +84,7 @@ agoo_ws_decode(char *buf, size_t mlen) {
84
84
  bool is_masked;
85
85
  uint8_t *payload;
86
86
  uint64_t plen;
87
-
87
+
88
88
  b++; // op
89
89
  is_masked = 0x80 & *b;
90
90
  plen = 0x7F & *b;
@@ -105,7 +105,7 @@ agoo_ws_decode(char *buf, size_t mlen) {
105
105
  if (is_masked) {
106
106
  uint8_t mask[4];
107
107
  uint64_t i;
108
-
108
+
109
109
  for (i = 0; i < 4; i++, b++) {
110
110
  mask[i] = *b;
111
111
  }
@@ -167,7 +167,7 @@ agoo_ws_calc_len(agooCon c, uint8_t *buf, size_t cnt) {
167
167
  bool
168
168
  agoo_ws_create_req(agooCon c, long mlen) {
169
169
  uint8_t op = 0x0F & *c->buf;
170
-
170
+
171
171
  if (NULL == (c->req = agoo_req_create(mlen))) {
172
172
  agoo_log_cat(&agoo_error_cat, "Out of memory attempting to allocate request.");
173
173
  return true;
@@ -200,7 +200,7 @@ void
200
200
  agoo_ws_req_close(agooCon c) {
201
201
  if (NULL != c->up && agoo_server.ctx_nil_value != c->up->ctx && c->up->on_close) {
202
202
  agooReq req = agoo_req_create(0);
203
-
203
+
204
204
  req->up = c->up;
205
205
  req->method = AGOO_ON_CLOSE;
206
206
  req->hook = agoo_hook_create(AGOO_NONE, NULL, c->up->ctx, PUSH_HOOK, &agoo_server.eval_queue);
@@ -212,37 +212,27 @@ agoo_ws_req_close(agooCon c) {
212
212
  void
213
213
  agoo_ws_ping(agooCon c) {
214
214
  agooRes res;
215
-
215
+
216
216
  if (NULL == (res = agoo_res_create(c))) {
217
217
  agoo_log_cat(&agoo_error_cat, "Memory allocation of response failed on connection %llu.", (unsigned long long)c->id);
218
218
  } else {
219
- if (NULL == c->res_tail) {
220
- c->res_head = res;
221
- } else {
222
- c->res_tail->next = res;
223
- }
224
- c->res_tail = res;
225
219
  res->close = false;
226
220
  res->con_kind = AGOO_CON_WS;
227
221
  res->ping = true;
222
+ agoo_con_res_append(c, res);
228
223
  }
229
224
  }
230
225
 
231
226
  void
232
227
  agoo_ws_pong(agooCon c) {
233
228
  agooRes res;
234
-
229
+
235
230
  if (NULL == (res = agoo_res_create(c))) {
236
231
  agoo_log_cat(&agoo_error_cat, "Memory allocation of response failed on connection %llu.", (unsigned long long)c->id);
237
232
  } else {
238
- if (NULL == c->res_tail) {
239
- c->res_head = res;
240
- } else {
241
- c->res_tail->next = res;
242
- }
243
- c->res_tail = res;
244
233
  res->close = false;
245
234
  res->con_kind = AGOO_CON_WS;
246
235
  res->pong = true;
236
+ agoo_con_res_append(c, res);
247
237
  }
248
238
  }
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Agoo
3
3
  # Agoo version.
4
- VERSION = '2.9.0'
4
+ VERSION = '2.10.0'
5
5
  end
@@ -24,7 +24,11 @@ class RackHandlerTest < Minitest::Test
24
24
  def call(req)
25
25
  if 'GET' == req['REQUEST_METHOD']
26
26
  [ 200,
27
- { 'Content-Type' => 'application/json' },
27
+ { 'Content-Type' => 'application/json',
28
+ 'Set-Cookie' => %|favorite=chocolate
29
+ size=big
30
+ |
31
+ },
28
32
  [ Oj.dump(req.to_h, mode: :null) ]
29
33
  ]
30
34
  elsif 'POST' == req['REQUEST_METHOD']
@@ -90,6 +94,7 @@ class RackHandlerTest < Minitest::Test
90
94
  res = Net::HTTP.start(uri.hostname, uri.port) { |h|
91
95
  h.request(req)
92
96
  }
97
+ assert_equal('favorite=chocolate, size=big', res['set-cookie'])
93
98
  content = res.body
94
99
  obj = Oj.load(content, mode: :strict)
95
100
  expect = {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 2.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-26 00:00:00.000000000 Z
11
+ date: 2019-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -78,6 +78,8 @@ files:
78
78
  - ext/agoo/gqlintro.h
79
79
  - ext/agoo/gqljson.c
80
80
  - ext/agoo/gqljson.h
81
+ - ext/agoo/gqlsub.c
82
+ - ext/agoo/gqlsub.h
81
83
  - ext/agoo/gqlvalue.c
82
84
  - ext/agoo/gqlvalue.h
83
85
  - ext/agoo/graphql.c