1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-17 01:32:37 +02:00

doc updates

This commit is contained in:
Kelly Brazil
2024-02-04 15:39:12 -08:00
parent cf77ddc396
commit bd6611aaba
5 changed files with 284 additions and 16 deletions

View File

@ -202,11 +202,66 @@ Schema:
Examples:
$ curl-head | jc --curl-head -p
[]
$ curl --head www.example.com | jc --curl-head -p
[
{
"type": "response",
"response_version": "HTTP/1.1",
"response_status": 200,
"response_reason": [
"OK"
],
"accept-ranges": [
"bytes"
],
"age": 241144,
"cache-control": [
"max-age=604800"
],
"content-type": "text/html; charset=UTF-8",
"date": "Sun, 04 Feb 2024 23:26:29 GMT",
"etag": "\"3147526947\"",
"expires": "Sun, 11 Feb 2024 23:26:29 GMT",
"last-modified": "Thu, 17 Oct 2019 07:18:26 GMT",
"server": [
"ECS (sac/2508)"
],
"x-cache": "HIT",
"content-length": 1256,
"date_epoch_utc": 1707089189,
"expires_epoch_utc": 1707693989,
"last-modified_epoch_utc": 1571296706
}
]
$ curl-head | jc --curl-head -p -r
[]
$ curl --head www.example.com | jc --curl-head -p -r
[
{
"type": "response",
"response_version": "HTTP/1.1",
"response_status": 200,
"response_reason": [
"OK"
],
"accept-ranges": [
"bytes"
],
"age": "225102",
"cache-control": [
"max-age=604800"
],
"content-type": "text/html; charset=UTF-8",
"date": "Sun, 04 Feb 2024 23:28:17 GMT",
"etag": "\"3147526947\"",
"expires": "Sun, 11 Feb 2024 23:28:17 GMT",
"last-modified": "Thu, 17 Oct 2019 07:18:26 GMT",
"server": [
"ECS (sac/2575)"
],
"x-cache": "HIT",
"content-length": "1256"
}
]
<a id="jc.parsers.curl_head.parse"></a>

View File

@ -207,11 +207,88 @@ Schema:
Examples:
$ curl-head | jc --curl-head -p
[]
$ cat headers.txt | jc --http-headers -p
[
{
"type": "request",
"request_method": "HEAD",
"request_uri": "/",
"request_version": "HTTP/1.1",
"host": "example.com",
"user-agent": "curl/8.1.2",
"accept": [
"*/*"
]
},
{
"type": "response",
"response_version": "HTTP/1.1",
"response_status": 200,
"response_reason": [
"OK"
],
"accept-ranges": [
"bytes"
],
"age": 140203,
"cache-control": [
"max-age=604800"
],
"content-type": "text/html; charset=UTF-8",
"date": "Sun, 04 Feb 2024 02:25:07 GMT",
"etag": "\"3147526947\"",
"expires": "Sun, 11 Feb 2024 02:25:07 GMT",
"last-modified": "Thu, 17 Oct 2019 07:18:26 GMT",
"server": [
"ECS (sac/252F)"
],
"x-cache": "HIT",
"content-length": 1256,
"date_epoch_utc": 1707013507,
"expires_epoch_utc": 1707618307,
"last-modified_epoch_utc": 1571296706
}
]
$ curl-head | jc --curl-head -p -r
[]
$ cat headers.txt | jc --http-headers -p -r
[
{
"type": "request",
"request_method": "HEAD",
"request_uri": "/",
"request_version": "HTTP/1.1",
"host": "example.com",
"user-agent": "curl/8.1.2",
"accept": [
"*/*"
]
},
{
"type": "response",
"response_version": "HTTP/1.1",
"response_status": 200,
"response_reason": [
"OK"
],
"accept-ranges": [
"bytes"
],
"age": "140203",
"cache-control": [
"max-age=604800"
],
"content-type": "text/html; charset=UTF-8",
"date": "Sun, 04 Feb 2024 02:25:07 GMT",
"etag": "\"3147526947\"",
"expires": "Sun, 11 Feb 2024 02:25:07 GMT",
"last-modified": "Thu, 17 Oct 2019 07:18:26 GMT",
"server": [
"ECS (sac/252F)"
],
"x-cache": "HIT",
"content-length": "1256"
}
]
<a id="jc.parsers.http_headers.parse"></a>

View File

@ -197,11 +197,66 @@ Schema:
Examples:
$ curl-head | jc --curl-head -p
[]
$ curl --head www.example.com | jc --curl-head -p
[
{
"type": "response",
"response_version": "HTTP/1.1",
"response_status": 200,
"response_reason": [
"OK"
],
"accept-ranges": [
"bytes"
],
"age": 241144,
"cache-control": [
"max-age=604800"
],
"content-type": "text/html; charset=UTF-8",
"date": "Sun, 04 Feb 2024 23:26:29 GMT",
"etag": "\"3147526947\"",
"expires": "Sun, 11 Feb 2024 23:26:29 GMT",
"last-modified": "Thu, 17 Oct 2019 07:18:26 GMT",
"server": [
"ECS (sac/2508)"
],
"x-cache": "HIT",
"content-length": 1256,
"date_epoch_utc": 1707089189,
"expires_epoch_utc": 1707693989,
"last-modified_epoch_utc": 1571296706
}
]
$ curl-head | jc --curl-head -p -r
[]
$ curl --head www.example.com | jc --curl-head -p -r
[
{
"type": "response",
"response_version": "HTTP/1.1",
"response_status": 200,
"response_reason": [
"OK"
],
"accept-ranges": [
"bytes"
],
"age": "225102",
"cache-control": [
"max-age=604800"
],
"content-type": "text/html; charset=UTF-8",
"date": "Sun, 04 Feb 2024 23:28:17 GMT",
"etag": "\"3147526947\"",
"expires": "Sun, 11 Feb 2024 23:28:17 GMT",
"last-modified": "Thu, 17 Oct 2019 07:18:26 GMT",
"server": [
"ECS (sac/2575)"
],
"x-cache": "HIT",
"content-length": "1256"
}
]
"""
from typing import List, Dict
from jc.jc_types import JSONDictType

View File

@ -202,11 +202,88 @@ Schema:
Examples:
$ curl-head | jc --curl-head -p
[]
$ cat headers.txt | jc --http-headers -p
[
{
"type": "request",
"request_method": "HEAD",
"request_uri": "/",
"request_version": "HTTP/1.1",
"host": "example.com",
"user-agent": "curl/8.1.2",
"accept": [
"*/*"
]
},
{
"type": "response",
"response_version": "HTTP/1.1",
"response_status": 200,
"response_reason": [
"OK"
],
"accept-ranges": [
"bytes"
],
"age": 140203,
"cache-control": [
"max-age=604800"
],
"content-type": "text/html; charset=UTF-8",
"date": "Sun, 04 Feb 2024 02:25:07 GMT",
"etag": "\"3147526947\"",
"expires": "Sun, 11 Feb 2024 02:25:07 GMT",
"last-modified": "Thu, 17 Oct 2019 07:18:26 GMT",
"server": [
"ECS (sac/252F)"
],
"x-cache": "HIT",
"content-length": 1256,
"date_epoch_utc": 1707013507,
"expires_epoch_utc": 1707618307,
"last-modified_epoch_utc": 1571296706
}
]
$ curl-head | jc --curl-head -p -r
[]
$ cat headers.txt | jc --http-headers -p -r
[
{
"type": "request",
"request_method": "HEAD",
"request_uri": "/",
"request_version": "HTTP/1.1",
"host": "example.com",
"user-agent": "curl/8.1.2",
"accept": [
"*/*"
]
},
{
"type": "response",
"response_version": "HTTP/1.1",
"response_status": 200,
"response_reason": [
"OK"
],
"accept-ranges": [
"bytes"
],
"age": "140203",
"cache-control": [
"max-age=604800"
],
"content-type": "text/html; charset=UTF-8",
"date": "Sun, 04 Feb 2024 02:25:07 GMT",
"etag": "\"3147526947\"",
"expires": "Sun, 11 Feb 2024 02:25:07 GMT",
"last-modified": "Thu, 17 Oct 2019 07:18:26 GMT",
"server": [
"ECS (sac/252F)"
],
"x-cache": "HIT",
"content-length": "1256"
}
]
"""
from typing import List, Dict
from jc.jc_types import JSONDictType

View File

@ -8,6 +8,10 @@ from tests import utils_for_test as test_utils
# - `{parser_name}--{some_test_description}.out` for command output.
# - `{parser_name}--{some_test_description}.json` for expected JSON after parsing.
# create output with:
# curl -ILvs http://google.com 2> curl_head--ILvs-google-com.out
# cat curl_head--ILvs-google-com.out | jc --curl-head > curl_head--ILvs-google-com.json
class MyTests(unittest.TestCase):
def test_curl_head_nodata(self):