From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: jsonrpc.el uses "Content-Length" headers which seem specific to LSP Date: Fri, 1 Dec 2023 00:45:56 +0000 Message-ID: References: <04f0ef0b-7fcf-4b09-a1c8-94960d8184cf@alphapapa.net> <87leby9n4m.fsf@gmail.com> <4d3cd934-01a8-41ac-b50b-61ff729c9a2c@alphapapa.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25369"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel , Joseph Turner To: Adam Porter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 01 01:47:16 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r8rga-0006MY-HR for ged-emacs-devel@m.gmane-mx.org; Fri, 01 Dec 2023 01:47:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r8rft-0007kn-V1; Thu, 30 Nov 2023 19:46:34 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r8rfb-0007fn-U6 for emacs-devel@gnu.org; Thu, 30 Nov 2023 19:46:18 -0500 Original-Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r8rfZ-0002iH-9p for emacs-devel@gnu.org; Thu, 30 Nov 2023 19:46:15 -0500 Original-Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-50bc2e7f1e4so2248984e87.1 for ; Thu, 30 Nov 2023 16:46:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701391569; x=1701996369; darn=gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Oe8yXlNdkM2pWN+WLtT2YVbQDTdkUV7l/036IZ4bGq8=; b=mYI182kQGgVA7vB+dTwCYvmoyyv2/eK+sqtfD5smJmVcOlfBCpOwnNwqoaPcrfdnb5 oo7LY2ImIgGl9N4RyZDlSGTVYppFBJR5FPm5nTsjLD2hZhMbgCGpQzJpGK99nWmLgj5R G6WPiRGVJ5MuLZdnIPTK4kw+adZAbqLFNP+fm/k7m6006V/VEWjfUDFVhFYzUntipifi 2RmMJzaiTtTanPBA8HQXt/XaAnulvjBcszNj9FUq4snERlXMxsLzZj7KCp7tnJ1p9OGB Idu8aLg2AUewb1mNbcRvg5jYNTYC7xlox8Cq15xH+NxolDt/kvqqY3cJzoLUL2+vtYEq OJ+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701391569; x=1701996369; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Oe8yXlNdkM2pWN+WLtT2YVbQDTdkUV7l/036IZ4bGq8=; b=AvTZSN1N//LepJrZ9XjKz/S+biBl9pUuCU5xXnWgO1GypP6EPsiYoTmt0mkIfIkqXT QEDuLsn4O0nN41FS6+6fQrJwiWnbTGhCxI1il2rtX+/RNTfN63XvgqQCQSezeXhDmYmm 4090Cts3nf9M59tW+IBIlDsc6u+JYjvsqsZX7HyYQugI14BbXCf/L5uMbKFelNmdnNYu anKkc1IVAaQe/QWo8n+4ll3JXZKtkTcJYNIAep/70GqW70Fm0gOAXUS/XC4T2wWiJJAw uhDz08fgGf9mcY7ZPOSDrlo9soCnfimYvD8qtVxOXQ+vQ511wj2xjW6g1Z3LZFJGbhmh Ri6A== X-Gm-Message-State: AOJu0YzuaCPC7aGx16hhq/mNHXCNScAbh4EhrXkRlnS8gv6pnyivGUdO mRFRGhMcnX1nheNP80ntAegC7NqZyqx4xt8/mdB/HCLp9nI= X-Google-Smtp-Source: AGHT+IHNtsgjwRhLCgem8z6mne+7mCV0fEUCi0q9ASa9ee1AYG4SaplLZ53ZKUzEmZty9JpCJ72HCc75Qjkrg9OlyIA= X-Received: by 2002:a05:6512:118a:b0:50b:d9d5:43cb with SMTP id g10-20020a056512118a00b0050bd9d543cbmr100888lfr.127.1701391569470; Thu, 30 Nov 2023 16:46:09 -0800 (PST) In-Reply-To: <4d3cd934-01a8-41ac-b50b-61ff729c9a2c@alphapapa.net> Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=joaotavora@gmail.com; helo=mail-lf1-x134.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:313411 Archived-At: Hi Adam, On Wed, Nov 22, 2023 at 10:41=E2=80=AFPM Adam Porter w= rote: > Thanks for this reply of yours from last month. I hadn't had anything > to add until now, after we've had more development in our project. Sorry for the delay from my side. > Given your experience with these things, does this seem like a > reasonable solution to you? I can't see why it wouldn't work, which just means I can't immediately find a flaw. I know from experience there are subtleties very easy to miss in these process filters. > Or is there still strong reason to prefer > using a Content-Length header to detect the end of responses? The drawbacks I see is (1) having to sweep through the data of every received chunk to look for the newline message separator and (2) all the escaping and un-escaping work. Whereas with Content-Length you read a number once, and continuously subtract from it to know if you have a full message. If you do, that's when json-parse-buffer is called, and that's when you sweep through the data to construct the JSON object. It's a more complicated parser but it's already written and it's proven sturdy. If I were coding this in C/C++ with performance and memory concerns it's also probably how I would go about it Here, I don't know if it makes a difference, you'd have to measure. Personally, if the other endpoint was under my control, I'd just add Content-Length for peace of mind. Seems easier than adding escaping anyways. Not sure if this reason is strong enough. Jo=C3=A3o