/
README.Rmd
150 lines (112 loc) · 3.19 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
httpcode
========
```{r echo=FALSE}
library("knitr")
hook_output <- knitr::knit_hooks$get("output")
knitr::knit_hooks$set(output = function(x, options) {
lines <- options$output.lines
if (is.null(lines)) {
return(hook_output(x, options)) # pass to default hook
}
x <- unlist(strsplit(x, "\n"))
more <- "..."
if (length(lines)==1) { # first n lines
if (length(x) > lines) {
# truncate the output, but add ....
x <- c(head(x, lines), more)
}
} else {
x <- c(if (abs(lines[1])>1) more else NULL,
x[lines],
if (length(x)>lines[abs(length(lines))]) more else NULL
)
}
# paste these lines together
x <- paste(c(x, ""), collapse = "\n")
hook_output(x, options)
})
knitr::opts_chunk$set(
warning = FALSE,
message = FALSE,
collapse = TRUE,
comment = "#>"
)
```
[![cran checks](https://badges.cranchecks.info/worst/httpcode.svg)](https://cloud.r-project.org/web/checks/check_results_httpcode.html)
[![R-check](https://github.com/sckott/httpcode/actions/workflows/R-check.yaml/badge.svg)](https://github.com/sckott/httpcode/actions/workflows/R-check.yaml)
[![codecov](https://codecov.io/gh/sckott/httpcode/branch/master/graph/badge.svg?token=gvEuPJXQuK)](https://codecov.io/gh/sckott/httpcode)
[![rstudio mirror downloads](https://cranlogs.r-pkg.org/badges/httpcode)](https://github.com/metacran/cranlogs.app)
[![cran version](https://www.r-pkg.org/badges/version/httpcode)](https://cran.r-project.org/package=httpcode)
`httpcode` is a tiny R package to search for and show http code messages and description. It's a port of the Python httpcode (https://github.com/rspivak/httpcode) library.
`httpcode` has no dependencies.
Follows RFC 2616 (https://www.ietf.org/rfc/rfc2616.txt), and for additional codes
following RFC 6585 (https://tools.ietf.org/html/rfc6585).
Structure of information for each status code:
* `status_code` - the status code
* `message` - very brief message explaining the code
* `explanation` - more verbose explanation, but still short
* `explanation_verbose` - the complete explanation
## Installation
Stable version
```{r eval=FALSE}
install.packages("httpcode")
```
Development version
```{r eval=FALSE}
install.packages("pak")
pak::pkg_install("sckott/httpcode")
```
```{r}
library("httpcode")
```
## Search by http code
```{r}
http_code(100)
```
```{r}
http_code(400)
```
```{r}
http_code(503)
```
```{r}
http_code(999)
```
## Get verbose status code description
```{r}
http_code(100, verbose = TRUE)
```
```{r}
http_code(400, verbose = TRUE)
```
# Fuzzy code search
```{r}
http_code('1xx')
```
```{r output.lines = 1:10}
http_code('3xx')
```
```{r}
http_code('30[12]')
```
```{r}
http_code('30[34]')
```
## Search by message
```{r output.lines = 1:10}
http_search("request")
```
```{r}
http_search("forbidden")
```
```{r}
http_search("too")
```
```{r}
http_search("birds")
```
## Bugs/features?
See [issues](https://github.com/sckott/httpcode/issues)
## Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct][coc]. By participating in this project you agree to abide by its terms.
[coc]: https://github.com/sckott/httpcode/blob/main/CODE_OF_CONDUCT.md