From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: swedebugia@riseup.net Newsgroups: gmane.lisp.guile.user Subject: Trouble parsing a response (Was: Re: New library: guile-wikidata) Date: Thu, 13 Dec 2018 08:06:33 -0800 Message-ID: References: <5ffe968620f1d2d940b7db2b1900dc43@riseup.net> <9f876db761468c16d1a6e0ee27c30821@riseup.net> <20181209110814.GA20268@tuxteam.de> <87tvjms87o.fsf@web.de> <33b7a105-8529-1043-c5bd-5b7fccefc042@gnu.org> <413312f3b999443b86b604ea9beff618@riseup.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=_092ea78cfb572724849719eccc33ee71" X-Trace: blaine.gmane.org 1544717138 13546 195.159.176.226 (13 Dec 2018 16:05:38 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 13 Dec 2018 16:05:38 +0000 (UTC) Cc: guile-user , guile-user@gnu.org To: Roel Janssen Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Dec 13 17:05:34 2018 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gXTUT-0003OM-EI for guile-user@m.gmane.org; Thu, 13 Dec 2018 17:05:33 +0100 Original-Received: from localhost ([::1]:53493 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXTWa-0007Ib-26 for guile-user@m.gmane.org; Thu, 13 Dec 2018 11:07:44 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXTVa-0006xl-3B for guile-user@gnu.org; Thu, 13 Dec 2018 11:06:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXTVZ-0001aD-4T for guile-user@gnu.org; Thu, 13 Dec 2018 11:06:42 -0500 Original-Received: from mx1.riseup.net ([198.252.153.129]:50033) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gXTVT-0001RZ-AG; Thu, 13 Dec 2018 11:06:35 -0500 Original-Received: from piha.riseup.net (piha-pn.riseup.net [10.0.1.163]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.riseup.net (Postfix) with ESMTPS id 4180A1A0611; Thu, 13 Dec 2018 08:06:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1544717194; bh=HK0Xwg3yt/V8fdJo6dInhr+HhzW+U3ZgP7jDIFtWRwQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=AzC6FmuJ+xnD3Ub9Oa86DkUwsvWXHH8WHSoW5+fIuKDYFIubehznKGVWmjs8gCZKD oYCfS6YJjZMp9tslTCvFX0BBe0f7Tzjc7/mQR6eaTpqeZcwVS/vt22TQAM2+AUXVTM 9Jsiigc3QYWajdf+5dhRWjZ4be+Yc3GJQo3TXOyo= X-Riseup-User-ID: 521BCA431FE0770866F777E454A3B4F36FF651948E32A5DC886ECCBB37A3DE4D Original-Received: from [127.0.0.1] (localhost [127.0.0.1]) by piha.riseup.net with ESMTPSA id 6506642D7E; Thu, 13 Dec 2018 08:06:33 -0800 (PST) In-Reply-To: <413312f3b999443b86b604ea9beff618@riseup.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 198.252.153.129 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:15069 Archived-At: --=_092ea78cfb572724849719eccc33ee71 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 2018-12-13 16:01, swedebugia@riseup.net wrote: snip >=20 > I tried with the file attached but got this because the driver does not > support URIs but only host, port, type, token: Ah, I saw now that you already implemented URI on master :) https://github.com/roelj/guile-sparql/blob/master/sparql/driver.scm When I try calling this ;; Example query to wikidata listing cats =20 =20 (sparql-query "SELECT ?item =20 =20 WHERE =20 =20 { =20 =20 ?item wdt:P31 wd:Q146. =20 =20 } =20 =20 LIMIT 10 =20 =20 " #:uri "https://query.wikidata.org/sparql" ;; #:port 80 =20 =20 #:type "application/sparql-results+json" ;; #:token "..." =20 =20 #:store-backend 'blazegraph ) I get this fine result: #< version: (1 . 1) code: 200 reason-phrase: "OK" headers: ((date . #) (content-type application/sparql-results+json (charset . "utf-8")) (transfer-encoding (chunked)) (connection close) (server . "nginx/1.13.6") (x-served-by . "wdqs1005") (access-control-allow-origin . "*") (cache-control public (max-age . 300)) (vary accept accept-encoding) (x-varnish . "644531744, 572094009, 417977651") (via "1.1 varnish (Varnish/5.1)" "1.1 varnish (Varnish/5.1)" "1.1 varnish (Varnish/5.1)") (accept-ranges bytes) (age . 0) (x-cache . "cp1079 pass, cp3030 pass, cp3030 pass") (x-cache-status . "pass") (server-timing . "cache;desc=3D\"pass\"") (strict-transport-security . "max-age=3D106384710; includeSubDomains; preload") (set-cookie . "WMF-Last-Access=3D13-Dec-2018;Path=3D/;HttpOnly;secure;Expires=3DMon, 14= Jan 2019 12:00:00 GMT") (set-cookie . "WMF-Last-Access-Global=3D13-Dec-2018;Path=3D/;Domain=3D.wikidata.org;Htt= pOnly;secure;Expires=3DMon, 14 Jan 2019 12:00:00 GMT") (x-analytics . "https=3D1;nocookies=3D1") (x-client-ip . "83.185.90.53")) port: #> My problem now is that I don't know how to separate the header from the port-file. Ah, reading here https://www.gnu.org/software/guile/manual/html_node/Responses.html#Respon= ses I found (response-port). Unfortunately this only took me one step further as I run into this instead when trying to parse the port with (json->scm): Backtrace: 7 (apply-smob/1 #) In ice-9/boot-9.scm: 705:2 6 (call-with-prompt _ _ #) In ice-9/eval.scm: 619:8 5 (_ #(#(#))) In ice-9/boot-9.scm: 2312:4 4 (save-module-excursion _) 3831:12 3 (_) In sdb-test.scm: 24:1 2 (_) In json/parser.scm: 311:18 1 (json-read-number _) 148:28 0 (read-number _) json/parser.scm:148:28: In procedure read-number: Throw to key `json-invalid' with args `(#>)'. Maybe this is a bug in (json)? Cheers=20 Swedebugia --=_092ea78cfb572724849719eccc33ee71 Content-Transfer-Encoding: base64 Content-Type: text/plain; name=sdb-test.scm Content-Disposition: attachment; filename=sdb-test.scm; size=727 KHVzZS1tb2R1bGVzIChzcGFycWwgZHJpdmVyKQogICAgICAgICAgICAgKHNwYXJxbCB1dGlsKQoJ ICAgICAoanNvbikKCSAgICAgKHdlYiByZXNwb25zZSkpCgo7OyBFeGFtcGxlIHF1ZXJ5IHRvIHdp a2lkYXRhIGxpc3RpbmcgY2F0cwooZGVmaW5lIHJlc3BvbnNlIChzcGFycWwtcXVlcnkKICAiU0VM RUNUID9pdGVtIApXSEVSRSAKewo/aXRlbSB3ZHQ6UDMxIHdkOlExNDYuCn0KTElNSVQgMTAKIgog ICM6dXJpICJodHRwczovL3F1ZXJ5Lndpa2lkYXRhLm9yZy9zcGFycWwiCiAgOzsgIzpwb3J0IDgw CiAgIzp0eXBlICJhcHBsaWNhdGlvbi9zcGFycWwtcmVzdWx0cytqc29uIgogIDs7ICAjOnRva2Vu ICIuLi4iCiAgIzpzdG9yZS1iYWNrZW5kICdibGF6ZWdyYXBoCiAgKSkKCgooZGlzcGxheQogKGpz b24tPnNjbQogIChyZXNwb25zZS1wb3J0IHJlc3BvbnNlKSkpCgo7OyAoanNvbi0+c2NtCjs7ICAo c3BhcnFsLXF1ZXJ5Cjs7ICAgIlNFTEVDVCA/aXRlbSAKOzsgV0hFUkUgCjs7IHsKOzsgP2l0ZW0g d2R0OlAzMSB3ZDpRMTQ2Lgo7OyB9Cjs7IExJTUlUIDEwCjs7ICIKOzsgICAjOnVyaSAiaHR0cHM6 Ly9xdWVyeS53aWtpZGF0YS5vcmcvc3BhcnFsIgo7OyAgIDs7ICM6cG9ydCA4MAo7OyAgICM6dHlw ZSAiYXBwbGljYXRpb24vc3BhcnFsLXJlc3VsdHMranNvbiIKOzsgICA7OyAgIzp0b2tlbiAiLi4u Igo7OyAgICM6c3RvcmUtYmFja2VuZCAnYmxhemVncmFwaAo7OyAgICkpCg== --=_092ea78cfb572724849719eccc33ee71--