agoo 2.15.4 → 2.15.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4f9e647ee51b00410d85de35a301d61dd6795175a2add858d29b4777d5889fb
4
- data.tar.gz: 707f1a41efc1f051c15f661774063b45e48f989377d14c9c5cf59579fb962f68
3
+ metadata.gz: ccb8962bfa94f61140bddb602034554e294c1e7258f61c03430604198afe05f4
4
+ data.tar.gz: c34075af5aa1ea5fdd94e2a0e87edb632f3ba084fd9d9e5ec04ce9969c7f40d8
5
5
  SHA512:
6
- metadata.gz: 896d35cc2800c9096192cf86d8595c1bf01f60f4b6509283d059911dbbc29ba5062fd03c38356d3bd29860d71a2f050d7c6ac5d12f011de699f8e5a9c33615af
7
- data.tar.gz: 140970f8d879fd73773688f3d1cb0b526834abe20077aa6b5e5b32e3c82c83359f74b425fc130df0ed64ac8727f41e74a69222d26eab9940d94640f91874dc92
6
+ metadata.gz: 8ff7a08ff29cfa24ca4f60e6915c5ceb2c2de1ec8b60f78e0ddcb5474c06d0462a95658c5663070a93d4024fff0081baec25ea5a653c450e672c1aade306626f
7
+ data.tar.gz: 8c42fbf4ba8f4fd1105594e566f19f290ebec1c8c8ed4460905d9730ff4c97eefcc456daba93c8969df8f4301a0758577b7489c2473d62d74f0b434e30385d7d
data/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  All changes to the Agoo gem are documented here. Releases follow semantic versioning.
4
4
 
5
+ ## [2.15.6] - 2023-07-07
6
+
7
+ ### Fixed
8
+
9
+ - Support for Apollo style POST requests fixed.
10
+
11
+ ## [2.15.5] - 2023-04-07
12
+
13
+ ### Changed
14
+
15
+ - Server static txt files now includes the UTF8 character set in the mime type tag.
16
+
5
17
  ## [2.15.4] - 2023-03-05
6
18
 
7
19
  ### Fixed
data/ext/agoo/con.c CHANGED
@@ -991,7 +991,6 @@ static void
991
991
  publish_pub(agooPub pub, agooConLoop loop) {
992
992
  agooUpgraded up;
993
993
  const char *sub = pub->subject->pattern;
994
- int cnt = 0;
995
994
 
996
995
  for (up = agoo_server.up_list; NULL != up; up = up->next) {
997
996
  if (NULL != up->con && up->con->loop == loop && agoo_upgraded_match(up, sub)) {
@@ -1001,7 +1000,6 @@ publish_pub(agooPub pub, agooConLoop loop) {
1001
1000
  agoo_con_res_append(up->con, res);
1002
1001
  res->con_kind = AGOO_CON_ANY;
1003
1002
  agoo_res_message_push(res, agoo_text_dup(pub->msg));
1004
- cnt++;
1005
1003
  }
1006
1004
  }
1007
1005
  }
@@ -112,5 +112,6 @@ void
112
112
  early_hints_init(VALUE mod) {
113
113
  eh_class = rb_define_class_under(mod, "EarlyHints", rb_cObject);
114
114
 
115
+ rb_undef_alloc_func(eh_class);
115
116
  rb_define_method(eh_class, "call", eh_call, 1);
116
117
  }
@@ -131,6 +131,7 @@ void
131
131
  error_stream_init(VALUE mod) {
132
132
  es_class = rb_define_class_under(mod, "ErrorStream", rb_cObject);
133
133
 
134
+ rb_undef_alloc_func(es_class);
134
135
  rb_define_method(es_class, "puts", es_puts, 1);
135
136
  rb_define_method(es_class, "write", es_write, 1);
136
137
  rb_define_method(es_class, "flush", es_flush, 0);
data/ext/agoo/page.c CHANGED
@@ -92,14 +92,14 @@ static struct _mime mime_map[] = {
92
92
  { "ppt", "application/vnd.ms-powerpoint" },
93
93
  { "ps", "application/postscript" },
94
94
  { "qt", "video/quicktime" },
95
- { "rb", "text/plain" },
95
+ { "rb", "text/plain; charset=utf-8" },
96
96
  { "rtf", "application/rtf" },
97
- { "sse", "text/plain" },
97
+ { "sse", "text/plain; charset=utf-8" },
98
98
  { "svg", "image/svg+xml" },
99
99
  { "tif", "image/tiff" },
100
100
  { "tiff", "image/tiff" },
101
101
  { "ttf", "application/font-sfnt" },
102
- { "txt", "text/plain" },
102
+ { "txt", "text/plain; charset=utf-8" }, // generally true and if it contains binary that would be an error anyway
103
103
  { "woff", "application/font-woff" },
104
104
  { "woff2", "font/woff2" },
105
105
  { "xls", "application/vnd.ms-excel" },
data/ext/agoo/request.c CHANGED
@@ -728,6 +728,7 @@ void
728
728
  request_init(VALUE mod) {
729
729
  req_class = rb_define_class_under(mod, "Request", rb_cObject);
730
730
 
731
+ rb_undef_alloc_func(req_class);
731
732
  rb_define_method(req_class, "to_s", to_s, 0);
732
733
  rb_define_method(req_class, "to_h", to_h, 0);
733
734
  rb_define_method(req_class, "environment", to_h, 0);
data/ext/agoo/rgraphql.c CHANGED
@@ -1054,6 +1054,8 @@ void
1054
1054
  graphql_init(VALUE mod) {
1055
1055
  graphql_class = rb_define_class_under(mod, "GraphQL", rb_cObject);
1056
1056
 
1057
+ rb_undef_alloc_func(graphql_class);
1058
+
1057
1059
  rb_define_module_function(graphql_class, "schema", graphql_schema, 1);
1058
1060
 
1059
1061
  rb_define_module_function(graphql_class, "load", graphql_load, 1);
data/ext/agoo/rresponse.c CHANGED
@@ -243,6 +243,7 @@ void
243
243
  response_init(VALUE mod) {
244
244
  res_class = rb_define_class_under(mod, "Response", rb_cObject);
245
245
 
246
+ rb_undef_alloc_func(res_class);
246
247
  rb_define_method(res_class, "to_s", to_s, 0);
247
248
  rb_define_method(res_class, "body", body_get, 0);
248
249
  rb_define_method(res_class, "body=", body_set, 1);
data/ext/agoo/rupgraded.c CHANGED
@@ -39,7 +39,7 @@ get_upgraded(VALUE self) {
39
39
  const char*
40
40
  extract_subject(VALUE subject, int *slen) {
41
41
  const char *subj;
42
-
42
+
43
43
  switch (rb_type(subject)) {
44
44
  case T_STRING:
45
45
  subj = StringValuePtr(subject);
@@ -84,7 +84,7 @@ rup_write(VALUE self, VALUE msg) {
84
84
  }
85
85
  } else {
86
86
  volatile VALUE rs = rb_funcall(msg, to_s_id, 0);
87
-
87
+
88
88
  message = StringValuePtr(rs);
89
89
  mlen = RSTRING_LEN(rs);
90
90
  }
@@ -165,7 +165,7 @@ static VALUE
165
165
  rup_pending(VALUE self) {
166
166
  agooUpgraded up = get_upgraded(self);
167
167
  int pending = -1;
168
-
168
+
169
169
  if (NULL != up) {
170
170
  pending = agoo_upgraded_pending(up);
171
171
  atomic_fetch_sub(&up->ref_cnt, 1);
@@ -183,7 +183,7 @@ static VALUE
183
183
  rup_open(VALUE self) {
184
184
  agooUpgraded up = get_upgraded(self);
185
185
  int pending = -1;
186
-
186
+
187
187
  if (NULL != up) {
188
188
  pending = (int)(long)atomic_load(&up->pending);
189
189
  atomic_fetch_sub(&up->ref_cnt, 1);
@@ -204,7 +204,7 @@ rup_protocol(VALUE self) {
204
204
 
205
205
  if (agoo_server.active) {
206
206
  agooUpgraded up;
207
-
207
+
208
208
  pthread_mutex_lock(&agoo_server.up_lock);
209
209
  if (NULL != (up = DATA_PTR(self)) && NULL != up->con) {
210
210
  switch (up->con->bind->kind) {
@@ -249,7 +249,7 @@ rupgraded_create(agooCon c, VALUE obj, VALUE env) {
249
249
  up->wrap = (void*)Data_Wrap_Struct(upgraded_class, NULL, NULL, up);
250
250
 
251
251
  agoo_server_add_upgraded(up);
252
-
252
+
253
253
  if (rb_respond_to(obj, on_open_id)) {
254
254
  rb_funcall(obj, on_open_id, 1, (VALUE)up->wrap);
255
255
  }
@@ -285,6 +285,7 @@ void
285
285
  upgraded_init(VALUE mod) {
286
286
  upgraded_class = rb_define_class_under(mod, "Upgraded", rb_cObject);
287
287
 
288
+ rb_undef_alloc_func(upgraded_class);
288
289
  rb_define_method(upgraded_class, "write", rup_write, 1);
289
290
  rb_define_method(upgraded_class, "subscribe", rup_subscribe, 1);
290
291
  rb_define_method(upgraded_class, "unsubscribe", rup_unsubscribe, -1);
data/ext/agoo/sdl.c CHANGED
@@ -22,6 +22,38 @@ static const char union_str[] = "union";
22
22
 
23
23
  static int make_sel(agooErr err, agooDoc doc, gqlDoc gdoc, gqlOp op, gqlSel *parentp);
24
24
 
25
+ /*
26
+ static void
27
+ debug_sels(gqlSel sel, int indent) {
28
+ char pad[100];
29
+
30
+ memset(pad, ' ', sizeof(pad));
31
+ pad[indent] = '\0';
32
+
33
+ printf("%s{%s %s", pad, sel->name, (NULL == sel->type) ? "NULL" : sel->type->name);
34
+ if (NULL == sel->sels) {
35
+ printf("}\n");
36
+ } else {
37
+ printf("\n");
38
+ for (gqlSel sc = sel->sels; NULL != sc; sc = sc->next) {
39
+ debug_sels(sc, indent + 2);
40
+ }
41
+ printf("%s}\n", pad);
42
+ }
43
+ }
44
+
45
+ static void
46
+ debug_doc(gqlDoc doc) {
47
+ printf("*** doc: {\n");
48
+ for (gqlOp op = doc->ops; NULL != op; op = op->next) {
49
+ printf(" {%s\n", op->name);
50
+ debug_sels(op->sels, 4);
51
+ }
52
+ printf(" }\n");
53
+ printf("}\n");
54
+ }
55
+ */
56
+
25
57
  static int
26
58
  extract_desc(agooErr err, agooDoc doc, const char **descp, size_t *lenp) {
27
59
  agoo_doc_skip_white(doc);
@@ -1312,10 +1344,51 @@ make_sel(agooErr err, agooDoc doc, gqlDoc gdoc, gqlOp op, gqlSel *parentp) {
1312
1344
  return AGOO_ERR_OK;
1313
1345
  }
1314
1346
 
1347
+ static gqlType
1348
+ lookup_field_type(gqlType type, const char *field, bool qroot) {
1349
+ gqlType ftype = NULL;
1350
+
1351
+ switch (type->kind) {
1352
+ case GQL_SCHEMA:
1353
+ case GQL_OBJECT:
1354
+ case GQL_INPUT:
1355
+ case GQL_INTERFACE: {
1356
+ gqlField f;
1357
+
1358
+ for (f = type->fields; NULL != f; f = f->next) {
1359
+ if (0 == strcmp(field, f->name)) {
1360
+ ftype = f->type;
1361
+ break;
1362
+ }
1363
+ }
1364
+ if (NULL == ftype) {
1365
+ if (0 == strcmp("__typename", field)) {
1366
+ ftype = &gql_string_type;
1367
+ } else if (qroot) {
1368
+ if (0 == strcmp("__type", field)) {
1369
+ ftype = gql_type_get("__Type");
1370
+ } else if (0 == strcmp("__schema", field)) {
1371
+ ftype = gql_type_get("__Schema");
1372
+ }
1373
+ }
1374
+ }
1375
+ break;
1376
+ }
1377
+ case GQL_LIST:
1378
+ case GQL_NON_NULL:
1379
+ ftype = lookup_field_type(type->base, field, false);
1380
+ break;
1381
+ case GQL_UNION: // Can not be used directly for query type determinations.
1382
+ default:
1383
+ break;
1384
+ }
1385
+ return ftype;
1386
+ }
1315
1387
 
1316
1388
  static int
1317
1389
  make_op(agooErr err, agooDoc doc, gqlDoc gdoc, gqlOpKind kind) {
1318
1390
  char name[256];
1391
+ const char *kind_str = query_str;
1319
1392
  const char *start;
1320
1393
  gqlOp op;
1321
1394
  size_t nlen;
@@ -1323,13 +1396,15 @@ make_op(agooErr err, agooDoc doc, gqlDoc gdoc, gqlOpKind kind) {
1323
1396
  agoo_doc_skip_white(doc);
1324
1397
  start = doc->cur;
1325
1398
  agoo_doc_read_token(doc);
1326
- if ( start < doc->cur) {
1399
+ if (start < doc->cur) {
1327
1400
  if (5 == (doc->cur - start) && 0 == strncmp(query_str, start, sizeof(query_str) - 1)) {
1328
1401
  kind = GQL_QUERY;
1329
1402
  } else if (8 == (doc->cur - start) && 0 == strncmp(mutation_str, start, sizeof(mutation_str) - 1)) {
1330
1403
  kind = GQL_MUTATION;
1404
+ kind_str = mutation_str;
1331
1405
  } else if (12 == (doc->cur - start) && 0 == strncmp(subscription_str, start, sizeof(subscription_str) - 1)) {
1332
1406
  kind = GQL_SUBSCRIPTION;
1407
+ kind_str = subscription_str;
1333
1408
  } else {
1334
1409
  return agoo_doc_err(doc, err, "Invalid operation type");
1335
1410
  }
@@ -1384,6 +1459,21 @@ make_op(agooErr err, agooDoc doc, gqlDoc gdoc, gqlOpKind kind) {
1384
1459
  if (doc->end <= doc->cur && '}' != doc->cur[-1]) {
1385
1460
  return agoo_doc_err(doc, err, "Expected a }");
1386
1461
  }
1462
+ if (0 < nlen) {
1463
+ gqlType schema = gql_root_type();
1464
+ gqlType type = lookup_field_type(schema, kind_str, false);
1465
+
1466
+ if ((NULL == lookup_field_type(type, op->sels->name, false)) &&
1467
+ (NULL != lookup_field_type(type, name, false))) {
1468
+ gqlSel wrap = sel_create(err, NULL, name, NULL);
1469
+
1470
+ if (NULL == wrap) {
1471
+ return err->code;
1472
+ }
1473
+ wrap->sels = op->sels;
1474
+ op->sels = wrap;
1475
+ }
1476
+ }
1387
1477
  if (NULL == gdoc->ops) {
1388
1478
  gdoc->ops = op;
1389
1479
  } else {
@@ -1461,47 +1551,6 @@ make_fragment(agooErr err, agooDoc doc, gqlDoc gdoc) {
1461
1551
  return AGOO_ERR_OK;
1462
1552
  }
1463
1553
 
1464
- static gqlType
1465
- lookup_field_type(gqlType type, const char *field, bool qroot) {
1466
- gqlType ftype = NULL;
1467
-
1468
- switch (type->kind) {
1469
- case GQL_SCHEMA:
1470
- case GQL_OBJECT:
1471
- case GQL_INPUT:
1472
- case GQL_INTERFACE: {
1473
- gqlField f;
1474
-
1475
- for (f = type->fields; NULL != f; f = f->next) {
1476
- if (0 == strcmp(field, f->name)) {
1477
- ftype = f->type;
1478
- break;
1479
- }
1480
- }
1481
- if (NULL == ftype) {
1482
- if (0 == strcmp("__typename", field)) {
1483
- ftype = &gql_string_type;
1484
- } else if (qroot) {
1485
- if (0 == strcmp("__type", field)) {
1486
- ftype = gql_type_get("__Type");
1487
- } else if (0 == strcmp("__schema", field)) {
1488
- ftype = gql_type_get("__Schema");
1489
- }
1490
- }
1491
- }
1492
- break;
1493
- }
1494
- case GQL_LIST:
1495
- case GQL_NON_NULL:
1496
- ftype = lookup_field_type(type->base, field, false);
1497
- break;
1498
- case GQL_UNION: // Can not be used directly for query type determinations.
1499
- default:
1500
- break;
1501
- }
1502
- return ftype;
1503
- }
1504
-
1505
1554
  static int
1506
1555
  sel_set_type(agooErr err, gqlType type, gqlSel sels, bool qroot) {
1507
1556
  gqlSel sel;
data/lib/agoo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Agoo
3
3
  # Agoo version.
4
- VERSION = '2.15.4'
4
+ VERSION = '2.15.6'
5
5
  end
data/test/graphql_test.rb CHANGED
@@ -428,6 +428,24 @@ directive @ruby(class: String!) on SCHEMA | OBJECT
428
428
  post_test(uri, body, 'application/json', expect)
429
429
  end
430
430
 
431
+ def test_post_json_op
432
+ uri = URI('http://localhost:6472/graphql?indent=2')
433
+ body = %^{
434
+ "query":"query artists{name}"
435
+ }^
436
+ expect = %^{
437
+ "data":{
438
+ "artists":[
439
+ {
440
+ "name":"Fazerdaze"
441
+ }
442
+ ]
443
+ }
444
+ }^
445
+
446
+ post_test(uri, body, 'application/json', expect)
447
+ end
448
+
431
449
  def test_post_fragment
432
450
  uri = URI('http://localhost:6472/graphql?indent=2')
433
451
  body = %^
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.15.4
4
+ version: 2.15.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-05 00:00:00.000000000 Z
11
+ date: 2023-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj