아래와 같이 실행하면, 의도와 바와 다르게 JSON(들여쓰기 지원))으로 출력이 되지 않습니다.
http(s) header / body 내용을 편하게 보고자 합니다.
json_pp도 설치해도, 제대로 동작하지 않네요
HTTP Header & Body를 모두 JSON형태로 출력하고자 합니다. <=============== !!!
해당 문제 해결을 위한 조언 부탁 드려 봅니다.
감사합니다.
----
#> curl -vks --head www.nhsung.com | jq '.'
* Trying 15.165.181.187:80...
* Connected to www.nhsung.com (15.165.181.187) port 80 (#0)
> HEAD / HTTP/1.1
> Host: www.nhsung.com
> User-Agent: curl/7.79.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Sun, 28 Aug 2022 10:01:33 GMT
< Content-Type: text/html
< Content-Length: 3520
< Connection: keep-alive
< Server: nginx/1.20.0
< Last-Modified: Tue, 12 Jul 2022 01:09:57 GMT
< ETag: "62ccc9e5-dc0"
< Accept-Ranges: bytes
<
* Connection #0 to host www.nhsung.com left intact
parse error: Invalid numeric literal at line 1, column 9
curl ¿É¼ÇÀ» À߸ø »ç¿ëÇÏ°í °è½Ê´Ï´Ù.
ÀúÀÇ °æ¿ì´Â Çì´õ ¹× ¹Ùµð¸¦ µ¿½Ã¿¡ JSON ÇüÅ·ΠÃâ·ÂÇÏ°í ÇÕ´Ï´Ù.
-i ¿É¼Ç Ãß°¡¸¦ Çϸé, header°¡ json ÇüÅ°¡ ¾Æ´Ï¿©¼ ±×·±Áö ½ÇÆÐÇÏ´Â Çö»óÀÌ ¹ß»ýÇÕ´Ï´Ù.
$ curl -sL -i 'https://ip-ranges.amazonaws.com/ip-ranges.json' | jq '.'
parse error: Invalid numeric literal at line 1, column 9
curl Ä¿¸Çµå ¾Æ´Ñ ´Ù¸¥ ¼Ö·ç¼ÇÀ» ã¾Æº¸¼¼¿ä.
ã¾Æº¸´Ï curl 7.84 ¹öÀü ºÎÅÍ -w "%{header_json}" ¸¦ ³ÖÀ¸¸é Çì´õ¸¦ jsonÀ¸·Î Ãâ·ÂÇØÁشٰí Çϳ׿ä.
./curl-amd64 https://ip-ranges.amazonaws.com/ip-ranges.json -w '%{header_json}' | jq -s '.[1] * .[0]'
..................... jq ¾î·Æ³×¿ä
¾î¶»°Ô Æ÷¸ÅÆÃÇؾߵǴÂÁö ¸ð¸£°Ú½À´Ï´Ù
À§¿¡¼ < Content-Type: text/html -> json typeÀ¸·Î responseÇÏ´Â URLÀ» ¿äûÇØ¾ß jq·Î Æ÷¸ÅÆÃÀÌ µÉ°Í °°³×¿ä.
À§¿Í °°Àº ¸í·ÉÀ¸·Î ½ÇÇà½Ã ¾Æ·¡¿Í °°Àº °á°ú¸¦ È®ÀÎ °¡´ÉÇϸç, °á°ú·Î ÃßÃøÇغ¸¸é... Amazon Linux¿¡¼ json¿¡ ´ëÇÑ ¼³Á¤ÀÌ µÇ¾î ÀÖÁö ¾ÊÀº°Í °°³×¿ä.
====================================================================================================================
Server: nginx/1.20.0
Last-Modified: Tue, 12 Jul 2022 01:09:57 GMT
ETag: "62ccc9e5-dc0"
Accept-Ranges: bytes
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Test Page for the Nginx HTTP Server on Amazon Linux</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
/*<![CDATA[*/
body {
background-color: #fff;
color: #000;
font-size: 0.9em;
font-family: sans-serif,helvetica;
margin: 0;
padding: 0;
}
:link {
color: #c00;
}
:visited {
color: #c00;
}
a:hover {
color: #f50;
}
h1 {
text-align: center;
margin: 0;
padding: 0.6em 2em 0.4em;
background-color: #294172;
color: #fff;
font-weight: normal;
font-size: 1.75em;
border-bottom: 2px solid #000;
}
h1 strong {
font-weight: bold;
font-size: 1.5em;
}
h2 {
text-align: center;
background-color: #3C6EB4;
font-size: 1.1em;
font-weight: bold;
color: #fff;
margin: 0;
padding: 0.5em;
border-bottom: 2px solid #294172;
}
hr {
display: none;
}
.content {
padding: 1em 5em;
}
.alert {
border: 2px solid #000;
}
img {
border: 2px solid #fff;
padding: 2px;
margin: 2px;
}
a:hover img {
border: 2px solid #294172;
}
.logos {
margin: 1em;
text-align: center;
}
/*]]>*/
</style>
</head>
<body>
<h1>Welcome to <strong>nginx</strong> on Amazon Linux!</h1>
<div class="content">
<p>This page is used to test the proper operation of the
<strong>nginx</strong> HTTP server after it has been
installed. If you can read this page, it means that the
web server installed at this site is working
properly.</p>
<div class="alert">
<h2>Website Administrator</h2>
<div class="content">
<p>This is the default <tt>index.html</tt> page that
is distributed with <strong>nginx</strong> on
Amazon Linux. It is located in
<tt>/usr/share/nginx/html</tt>.</p>
<p>You should now put your content in a location of
your choice and edit the <tt>root</tt> configuration
directive in the <strong>nginx</strong>
configuration file
<tt>/etc/nginx/nginx.conf</tt>.</p>
</div>
</div>
<div class="logos">
<a href="http://nginx.net/"><img
src="nginx-logo.png"
alt="[ Powered by nginx ]"
width="121" height="32" /></a>
</div>
</div>
</body>
</html>
====================================================================================================================