{"id":13706666,"url":"https://github.com/hrbrmstr/construe","last_synced_at":"2025-10-29T01:30:49.432Z","repository":{"id":141238066,"uuid":"291078964","full_name":"hrbrmstr/construe","owner":"hrbrmstr","description":"🧰  HTTP Request, Response and URL Parser","archived":false,"fork":false,"pushed_at":"2020-09-01T03:02:17.000Z","size":83,"stargazers_count":6,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"batman","last_synced_at":"2025-02-01T20:51:13.683Z","etag":null,"topics":["http-parser","r","rstats"],"latest_commit_sha":null,"homepage":"https://cinc.rud.is/web/packages/construe/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hrbrmstr.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-08-28T15:18:58.000Z","updated_at":"2021-01-06T00:21:11.000Z","dependencies_parsed_at":"2024-01-14T20:18:44.442Z","dependency_job_id":"15dd742b-756e-4615-874d-4ab896a0980b","html_url":"https://github.com/hrbrmstr/construe","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrbrmstr%2Fconstrue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrbrmstr%2Fconstrue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrbrmstr%2Fconstrue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrbrmstr%2Fconstrue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hrbrmstr","download_url":"https://codeload.github.com/hrbrmstr/construe/tar.gz/refs/heads/batman","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238752437,"owners_count":19524760,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http-parser","r","rstats"],"created_at":"2024-08-02T22:01:04.440Z","updated_at":"2025-10-29T01:30:44.109Z","avatar_url":"https://github.com/hrbrmstr.png","language":"C++","readme":"---\noutput: rmarkdown::github_document\neditor_options: \n  chunk_output_type: console\n---\n```{r pkg-knitr-opts, include=FALSE}\nhrbrpkghelpr::global_opts()\n```\n\n```{r badges, results='asis', echo=FALSE, cache=FALSE}\nhrbrpkghelpr::stinking_badges(branch = \"batman\")\n```\n\n```{r description, results='asis', echo=FALSE, cache=FALSE}\nhrbrpkghelpr::yank_title_and_description()\n```\n\n## What's Inside The Tin\n\nThe following functions are implemented:\n\n```{r ingredients, results='asis', echo=FALSE, cache=FALSE}\nhrbrpkghelpr::describe_ingredients()\n```\n\n## Installation\n\n```{r install-ex, results='asis', echo=FALSE, cache=FALSE}\nhrbrpkghelpr::install_block()\n```\n\n## Usage\n\n```{r lib-ex}\nlibrary(construe)\n\n# current version\npackageVersion(\"construe\")\n\n```\n\n### Requests\n\n```{r ex01}\npaste0(c(\n  \"GET /uri.cgi HTTP/1.1\\r\\n\",\n  \"User-Agent: Mozilla/5.0\\r\\n\",\n  \"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\\r\\n\",\n  \"Host: 127.0.0.1\\r\\n\", \"\\r\\n\"\n), collapse = \"\") -\u003e req\n\nreq_raw \u003c- charToRaw(req)\n\nparse_request(req)\n\nparse_request_raw(req_raw)\n\nmicrobenchmark::microbenchmark(\n  parse_request = parse_request(req),\n  parse_request_raw = parse_request_raw(req_raw)\n)\n```\n\n\n### Responses\n\n```{r ex02}\npaste0(c(\n  \"HTTP/1.1 200 OK\\r\\n\",\n  \"Server: nginx/1.2.1\\r\\n\",\n  \"Content-Type: text/html\\r\\n\",\n  \"Content-Length: 8\\r\\n\",\n  \"Connection: keep-alive\\r\\n\",\n  \"\\r\\n\",\n  \"\u003chtml /\u003e\"\n), collapse = \"\") -\u003e resp\n\nresp_raw \u003c- charToRaw(resp)\n\nparse_response(resp)\n\nparse_response_raw(resp_raw)\n\nmicrobenchmark::microbenchmark(\n  parse_response = parse_response(resp),\n  parse_response_raw = parse_response_raw(resp_raw)\n)\n```\n\n### curl output example\n\n`HEAD` request:\n\n```{r curl-01}\nsys::exec_internal(\n  cmd = \"curl\", \n  args = c(\"--include\", \"--head\", \"--silent\", \"https://httpbin.org/\")\n) -\u003e res\n\nstr(parse_response(rawToChar(res$stdout)), 2)\n\ncurl::curl_fetch_memory(\n \"https://httpbin.org/\",\n handle = curl::new_handle(\n  nobody = TRUE\n )\n) -\u003e res\n\nstr(construe::parse_response_raw(res$headers), 2)\n\ncurl::curl_fetch_memory(\n \"http://rud.is/b\",\n handle = curl::new_handle(\n  nobody = TRUE,\n  followlocation = TRUE\n )\n) -\u003e res\n\nrawToChar(res$headers) %\u003e% \n strsplit(\"(?m)\\r\\n\\r\\n\", perl = TRUE) %\u003e% \n unlist() %\u003e% \n lapply(construe::parse_response) %\u003e% \n str(2)\n```\n\n`GET` request:\n\n```{r curl-02}\nsys::exec_internal(\n  cmd = \"curl\", \n  args = c(\"--include\", \"--silent\", \"https://httpbin.org/\")\n) -\u003e res\n\nstr(parse_response_raw(res$stdout), 2)\n\nres \u003c- curl::curl_fetch_memory(\"https://httpbin.org/\")\n\nstr(construe::parse_response_raw(res$headers), 2)\n```\n\n### URLs\n\n```{r ex03}\nc(\n  \"git+ssh://example.com/path/file\",\n  \"https://example.com/path/file\",\n  \"http://www.example.com/dir/subdir?param=1\u0026param=2;param%20=%20#fragment\",\n  \"http://www.example.com\",\n  \"http://username@www.example.com/dir/subdir?param=1\u0026param=2;param%20=%20#fragment\",\n  \"http://username:passwd@www.example.com/dir/subdir?param=1\u0026param=2;param%20=%20#fragment\",\n  \"http://www.example.com:8080/dir/subdir?param=1\u0026param=2;param%20=%20#fragment\",\n  \"http://username:passwd@www.example.com:8080/dir/subdir?param=1\u0026param=2;param%20=%20#fragment\",\n  \"ftp://username:passwd@ftp.example.com/dir/filename.ext\",\n  \"mailto:username@example.com\",\n  \"svn+ssh://hostname-01.org/path/to/file\",\n  \"xddp::://///blah.wat/?\"\n) -\u003e turls\n\nparse_url(turls)\n\nmicrobenchmark::microbenchmark(\n  parse_url = parse_url(turls[1])\n)\n```\n\n### Parse headers from Palo Alto `HEAD` requests\n\n```{r why}\nhdr \u003c- read_file_raw(system.file(\"extdat\", \"example.hdr\", package = \"construe\"))\n\ncat(rawToChar(hdr))\n\nparse_response_raw(hdr)\n```\n\n## construe Metrics\n\n```{r cloc, echo=FALSE}\ncloc::cloc_pkg_md()\n```\n\n## Code of Conduct\n\nPlease note that this project is released with a Contributor Code of Conduct. \nBy participating in this project you agree to abide by its terms.\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhrbrmstr%2Fconstrue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhrbrmstr%2Fconstrue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhrbrmstr%2Fconstrue/lists"}