You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
2.9 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. [![Project Status: Active – The project has reached a stable, usable
  2. state and is being actively
  3. developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
  4. [![Signed
  5. by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keybase.io/hrbrmstr)
  6. ![Signed commit
  7. %](https://img.shields.io/badge/Signed_Commits-100%25-lightgrey.svg)
  8. [![R-CMD-check](https://github.com/hrbrmstr/httr2curl/workflows/R-CMD-check/badge.svg)](https://github.com/hrbrmstr/httr2curl/actions?query=workflow%3AR-CMD-check)
  9. [![Linux build
  10. Status](https://travis-ci.org/hrbrmstr/httr2curl.svg?branch=master)](https://travis-ci.org/hrbrmstr/httr2curl)
  11. ![Minimal R
  12. Version](https://img.shields.io/badge/R%3E%3D-3.6.0-blue.svg)
  13. ![License](https://img.shields.io/badge/License-MIT-blue.svg)
  14. # httr2curl
  15. Turn ‘httr’ Web Requests Into ‘curl’ Command Line Calls
  16. ## Description
  17. When provided with an ‘httr’ “VERB” call, the request will be made and
  18. ‘libcurl’ headers will be captured and post-processed to provide a
  19. working ‘curl’ command line call.
  20. ## What’s Inside The Tin
  21. The following functions are implemented:
  22. - `h2c`: Convert an ‘httr’ call to ‘curl’ command line
  23. ## Installation
  24. ``` r
  25. remotes::install_git("https://git.rud.is/hrbrmstr/httr2curl.git")
  26. ```
  27. NOTE: To use the ‘remotes’ install options you will need to have the
  28. [{remotes} package](https://github.com/r-lib/remotes) installed.
  29. ## Usage
  30. ``` r
  31. library(httr2curl)
  32. # current version
  33. packageVersion("httr2curl")
  34. ## [1] '0.1.0'
  35. ```
  36. ### Using local perl
  37. ``` r
  38. h2c(
  39. httr::GET(
  40. url = "https://rud.is/",
  41. httr::user_agent(splashr::ua_apple_tv),
  42. query = list(
  43. a = "b",
  44. c = 1
  45. )
  46. )
  47. )
  48. ## [1] "curl --http2 --header \"Accept: application/json, text/xml, application/xml, */*\" --compressed --user-agent \"AppleTV6,2/11.1\" \"https://rud.is/?a=b&c=1\""
  49. ```
  50. ### Using the web service
  51. ``` r
  52. h2c(
  53. httr::GET(
  54. url = "https://rud.is/",
  55. httr::user_agent(splashr::ua_apple_tv),
  56. query = list(
  57. a = "b",
  58. c = 1
  59. )
  60. ),
  61. use_web_service = TRUE
  62. )
  63. ## [1] "curl --header \"Accept: application/json, text/xml, application/xml, */*\" --compressed --user-agent \"AppleTV6,2/11.1\" \"https://rud.is/?a=b&c=1\""
  64. ```
  65. ## httr2curl Metrics
  66. | Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) |
  67. |:-----|---------:|-----:|----:|-----:|------------:|-----:|---------:|-----:|
  68. | R | 5 | 0.36 | 49 | 0.24 | 21 | 0.25 | 40 | 0.26 |
  69. | Rmd | 1 | 0.07 | 29 | 0.14 | 19 | 0.23 | 35 | 0.23 |
  70. | YAML | 1 | 0.07 | 22 | 0.11 | 2 | 0.02 | 2 | 0.01 |
  71. | SUM | 7 | 0.50 | 100 | 0.50 | 42 | 0.50 | 77 | 0.50 |
  72. clock Package Metrics for httr2curl
  73. ## Code of Conduct
  74. Please note that this project is released with a Contributor Code of
  75. Conduct. By participating in this project you agree to abide by its
  76. terms.