From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id WEn9Gj/zEme7swAAe85BDQ:P1 (envelope-from ) for ; Fri, 18 Oct 2024 23:46:07 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id WEn9Gj/zEme7swAAe85BDQ (envelope-from ) for ; Sat, 19 Oct 2024 01:46:07 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1729295167; a=rsa-sha256; cv=none; b=cIx8emNBiBV7pIgQ2mUqgBix8zGHBPRB/AFmxoXgodNf2dCABfMKzvUbq7EW7MW4v4+r+r mARojISnO2UcutxFb5vYc26xwJG90K3n3sPWKTHAxgDiRc0O46SnW5ztg/bkOZ/MR+89Ya c/cyr7qCQrZSBeldYtK8awBojLv37uy1U1vkG0AicZTMzMsKnIBaNGpYVfqrSPYiuBPNex NA6GsdX4pRAivxCgxGfZf1xR1XLJS3roEXZxJjsvkNKNQtYRgiZQfS7x3w9YdcCy5uK54b b/OiRbGZI0mFw1Dy8dWz+MJvqpObj3gBUxsBbQ0Y+Aesz4t8TQwiBs2mfVoXOg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1729295167; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=w6LXO4v/X9J0s01iGG1ZoAVMh9YnA+1f6Nwr44SMT0U=; b=YX/6V/m5v+J9IuYI2BExS2XxBVP+A4WVEap9mDTwWOiZKNssvQi/OUgXBpp0vAUWHlY74M GbluMPmHagcvSptZzTjA6oGlKn2ToAMA2rUfaCOjNuQGrpux8SzjMX4L/LbHL+QgpxNnf8 Dr/vlxfkjLfFriBJS5RtTC66phEO8r6kJQCovAOsLVOpEvJMOhZaHv99T0PHV46MnrLlA8 tZOcwZGmZdABSLjkh2oSgVNGfJ7yEOmONL1eQ1bdbOvAP5ivQkcMmCcHTsTdZoozEJ4Gmo Cp335gljso5b+BXMBf+h7xdSCu/G2oOdvfgInk1ihCBtcQK9iot+sUkHU/DdYA== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 98F8365E65 for ; Sat, 19 Oct 2024 01:46:06 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t1wed-0000TN-6T; Fri, 18 Oct 2024 19:45:11 -0400 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 1t1web-0000Si-Ga for emacs-orgmode@gnu.org; Fri, 18 Oct 2024 19:45:09 -0400 Received: from smtpout1.mo11.mail-out.ovh.ca ([51.161.45.253]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t1weY-0004Ji-JZ for emacs-orgmode@gnu.org; Fri, 18 Oct 2024 19:45:08 -0400 Received: from mxplan1.mail.ovh.ca (unknown [10.111.58.46]) by mo11.mail-out.ovh.ca (Postfix) with ESMTPS id 4XVhC31DJZzHpyM; Fri, 18 Oct 2024 20:45:03 -0300 (ADT) Received: from morales.pe (54.39.251.57) by DAG2EX2.mxpca1.local (172.16.2.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 18 Oct 2024 19:45:02 -0400 X-OVh-ClientIp: 190.233.209.18 From: Rodrigo Morales To: Bruno Barbier , Subject: Re: Why Emacs shows ^M at the end of some lines in sh code blocks that use curl? In-Reply-To: <67115424.df0a0220.20f4.03e0@mx.google.com> References: <87r08eepm4.fsf@morales.pe> <67115424.df0a0220.20f4.03e0@mx.google.com> Date: Fri, 18 Oct 2024 18:44:56 -0500 Message-ID: <87y12lc6x3.fsf@morales.pe> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [54.39.251.57] X-ClientProxiedBy: DAG1EX2.mxpca1.local (172.16.2.2) To DAG2EX2.mxpca1.local (172.16.2.12) X-Ovh-Tracer-GUID: 37301fc0-ece4-4c82-a143-9de0f74aa57b X-Ovh-Tracer-Id: 17509713877567379098 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeeftddrvdehgedgvdehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvffujghffffkgggtihesthdtredttddttdenucfhrhhomheptfhoughrihhgohcuofhorhgrlhgvshcuoehrohgurhhighhoqdhmrghilhhinhhgqdhlihhsthhssehmohhrrghlvghsrdhpvgeqnecuggftrfgrthhtvghrnhepvefgteetheelhfekgeefvddtfeffieelgfefgfetleeiheduheeuhfektdffleeunecuffhomhgrihhnpehsthgrtghkohhvvghrfhhlohifrdgtohhmpdhfihhlvghsrghmphhlvghshhhusgdrtghomhenucfkphepuddvjedrtddrtddruddpheegrdefledrvdehuddrheejpdduledtrddvfeefrddvtdelrddukeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomheprhhoughrihhgohdqmhgrihhlihhnghdqlhhishhtshesmhhorhgrlhgvshdrphgvpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepsghruhgsrghrrdgtshesghhmrghilhdrtghomhdprhgtphhtthhopegvmhgrtghsqdhorhhgmhhouggvsehgnhhurdhorhhgpdfovfetjfhoshhtpehmohduuddpmhhouggvpehsmhhtphhouhht Received-SPF: pass client-ip=51.161.45.253; envelope-from=rodrigo-mailing-lists@morales.pe; helo=smtpout1.mo11.mail-out.ovh.ca X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: 1.49 X-Spam-Score: 1.49 X-Migadu-Queue-Id: 98F8365E65 X-Migadu-Scanner: mx12.migadu.com X-TUID: uPc7nm/3xddn Bruno Barbier writes: > it's not related to Org (HTTP headers use '\r\n', your JSON Thanks for pointing me in the right direction. I searched related information on the Internet and I found out there is an specific section in Request for Comments (RFC2616) that explicitly states that '\r\n' should be used as the line break for HTTP headers. I learned this from https://stackoverflow.com/a/5757349 > You could include a translation step. For example, using 'tr': > > #+begin_src shell :results raw > curl --include --silent https://filesampleshub.com/download/code/json/sample1.json | tr -d '\r' > #+end_src > > If you are fetching arbitrary data, you do not want to do that though. > You may ask curl to dump the headers in a file, and translate only > that file (using --dump-header). I agree with you on not using tr -d '\r' for both the response body and the response headers. Starting from now, when I feel the need to show the response headers in my notes, I'll dump the headers to a file and then show pass that file to 'tr' as shown below: #+begin_src sh curl --dump-header /tmp/curl-header.txt --silent --request GET 'https://filesampleshub.com/download/code/json/sample1.json' echo '----' cat /tmp/curl-header.txt | tr -d '\r' #+end_src #+RESULTS: #+begin_example { "fear": "quiet", "chest": -1477429467, "how": false, "graph": false, "camp": 929234312, "plural": "settle" }---- HTTP/2 200 accept-ranges: bytes access-control-allow-origin: * age: 3641498 cache-control: public, max-age=0, must-revalidate content-disposition: inline; filename="sample1.json" content-type: application/json; charset=utf-8 date: Fri, 18 Oct 2024 22:43:39 GMT etag: "c4b4a9669841a9ab437f5dce6c9c9230" last-modified: Fri, 06 Sep 2024 19:12:01 GMT server: Vercel strict-transport-security: max-age=63072000 x-matched-path: /download/code/json/sample1.json x-vercel-cache: HIT x-vercel-id: gru1::9cdc6-1729291419743-bcee78204a79 content-length: 136 #+end_example Sometimes when I want to focus on the behavior of an API and don't write such long command due to that technical detail, I could simply use restclient. See example below (in my system, the header lines shown by restclient don't show the ^M character) #+begin_src restclient GET https://filesampleshub.com/download/code/json/sample1.json #+end_src #+RESULTS: #+BEGIN_SRC js { "fear": "quiet", "chest": -1477429467, "how": false, "graph": false, "camp": 929234312, "plural": "settle" } // GET https://filesampleshub.com/download/code/json/sample1.json // HTTP/1.1 200 OK // Accept-Ranges: bytes // Access-Control-Allow-Origin: * // Age: 3641582 // Cache-Control: public, max-age=0, must-revalidate // Content-Disposition: inline; filename="sample1.json" // Content-Length: 136 // Content-Type: application/json; charset=utf-8 // Date: Fri, 18 Oct 2024 22:45:03 GMT // Etag: "c4b4a9669841a9ab437f5dce6c9c9230" // Last-Modified: Fri, 06 Sep 2024 19:12:01 GMT // Server: Vercel // Strict-Transport-Security: max-age=63072000 // X-Matched-Path: /download/code/json/sample1.json // X-Vercel-Cache: HIT // X-Vercel-Id: gru1::4ktmb-1729291503557-396fe6c0ce31 // Request duration: 0.258368s #+END_SRC