{"id":329723,"date":"2022-02-17T09:00:14","date_gmt":"2022-02-17T09:00:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=329723"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=329723","title":{"rendered":"<span>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 API \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 R, \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u043f\u0430\u043a\u0435\u0442 httr2<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0426\u0435\u043b\u044c \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 &#8212; \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u043e\u0441\u043d\u043e\u0432\u044b <code>httr2<\/code>.\u00a0<\/p>\n<p><code>httr2<\/code> &#8212; \u043f\u0435\u0440\u0435\u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u0430 <code>httr<\/code>, \u0442.\u0435. \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 R.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bf8\/b08\/99a\/bf8b0899a56bb7aa596a3c497a6962b4.png\" width=\"900\" height=\"492\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bf8\/b08\/99a\/bf8b0899a56bb7aa596a3c497a6962b4.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c\u0438 HTTP-\u043e\u0442\u0432\u0435\u0442\u0430\u043c\u0438.\u00a0<code>httr2<\/code> \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u0434\u043b\u044f \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c HTTP, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043e\u0431\u044a\u044f\u0441\u043d\u044e \u043f\u043e \u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f.\u00a0\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u044f \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u0442\u0430\u0442\u044c\u0451\u0439 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Overview\" rel=\"noopener noreferrer nofollow\">&#171;An overview of HTTP&#187;<\/a> \u043e\u0442 MDN.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c <code>httr2<\/code>.<\/p>\n<pre><code class=\"r\">install.packages(\"httr2\") library(httr2)<\/code><\/pre>\n<h2>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435<\/h2>\n<p><em>\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442\u0435\u0441\u044c \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u0430\u043c \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u043c\u043e\u0438\u00a0<\/em><a href=\"https:\/\/t.me\/R4marketing\" rel=\"noopener noreferrer nofollow\"><em>telegram<\/em><\/a><em>\u00a0\u0438\u00a0<\/em><a href=\"https:\/\/www.youtube.com\/R4marketing\/?sub_confirmation=1\" rel=\"noopener noreferrer nofollow\"><em>youtube<\/em><\/a><em>\u00a0\u043a\u0430\u043d\u0430\u043b\u044b. \u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u044b \u044f\u0437\u044b\u043a\u0443 R.<\/em><\/p>\n<ol>\n<li>\n<p><a href=\"#create_request\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#get_response\" rel=\"noopener noreferrer nofollow\">\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0442\u0432\u0435\u0442\u0430<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#request_process\" rel=\"noopener noreferrer nofollow\">\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#from_author\" rel=\"noopener noreferrer nofollow\">\u041e\u0442 \u0430\u0432\u0442\u043e\u0440\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430<\/a><\/p>\n<\/li>\n<\/ol>\n<p><a class=\"anchor\" name=\"create_request\" id=\"create_request\"><\/a><\/p>\n<h2>\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/h2>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 <code>httr2<\/code> \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u042d\u0442\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u0430 <code>httr<\/code>, \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0432\u044b \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0438 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439: \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u0438 \u0435\u0433\u043e, \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u0438 \u043e\u0442\u0432\u0435\u0442. <code>httr2<\/code> \u0438\u043c\u0435\u0435\u0442 \u044f\u0432\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e URL:<\/p>\n<pre><code class=\"r\">req &lt;- request(\"https:\/\/httpbin.org\/get\") req #> &lt;httr2_request> #> GET https:\/\/httpbin.org\/get #> Body: empty<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e:<\/p>\n<pre><code class=\"r\">req %>% req_dry_run() #> GET \/get HTTP\/1.1 #> Host: httpbin.org #> User-Agent: httr2\/0.1.1 r-curl\/4.3.2 libcurl\/7.64.1 #> Accept: *\/* #> Accept-Encoding: deflate, gzip<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u0440\u0438 \u0432\u0430\u0436\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/p>\n<ul>\n<li>\n<p>HTTP\u00a0<strong>\u043c\u0435\u0442\u043e\u0434<\/strong>, \u0442.\u0435. \u0433\u043b\u0430\u0433\u043e\u043b,\u00a0\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0443,\u00a0\u043a\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441.\u00a0\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 GET, \u0441\u0430\u043c\u044b\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439, \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c\u00a0<em>\u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c<\/em>\u00a0\u0440\u0435\u0441\u0443\u0440\u0441 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.\u00a0\u0414\u0440\u0443\u0433\u0438\u0435 \u0442\u0430\u043a \u0436\u0435 \u0435\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 HTTP \u043c\u0435\u0442\u043e\u0434\u044b: POST, \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u0430, PUT, \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u0430, \u0438 DELETE, \u0434\u043b\u044f \u0435\u0433\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0443\u0442\u044c<\/strong>, URL \u0430\u0434\u0440\u0435\u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437: \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 (<code>http<\/code>\u0438\u043b\u0438\u00a0<code>https<\/code>), \u0445\u043e\u0441\u0442\u0430 (<code>httpbin.org<\/code>), \u0438 \u043f\u043e\u0440\u0442\u0430 (\u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f).<\/p>\n<\/li>\n<li>\n<p>\u0412\u0435\u0440\u0441\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 HTTP.\u00a0\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043d\u0430\u043c \u043d\u0435 \u0432\u0430\u0436\u043d\u0430, \u0442.\u043a. \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0438\u0434\u0451\u0442 \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043d\u0438\u0437\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0438\u0434\u0443\u0442\u00a0<strong>\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438<\/strong>\u00a0\u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u0445 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u0432 \u0432\u0438\u0434\u0435 \u043f\u0430\u0440 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u043a\u043e\u043c\u00a0<code>:<\/code>.\u00a0\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0431\u044b\u043b\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b <code>httr2<\/code>, \u043d\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0438\u0445 \u0438\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<code>req_headers()<\/code>:<\/p>\n<pre><code class=\"r\">req %>%  req_headers(  Name = \"Hadley\",   `Shoe-Size` = \"11\",   Accept = \"application\/json\"  ) %>%   req_dry_run() #> GET \/get HTTP\/1.1 #> Host: httpbin.org #> User-Agent: httr2\/0.1.1 r-curl\/4.3.2 libcurl\/7.64.1 #> Accept-Encoding: deflate, gzip #> Name: Hadley #> Shoe-Size: 11 #> Accept: application\/json<\/code><\/pre>\n<p>\u0418\u043c\u0435\u043d\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u043d\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b \u043a \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443, \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044e\u0442 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0438\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438.<\/p>\n<p>\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043b\u0435\u0434\u0443\u0435\u0442\u00a0<strong>\u0442\u0435\u043b\u043e<\/strong>\u00a0\u0437\u0430\u043f\u0440\u043e\u0441\u0430.\u00a0\u041f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b (\u043a\u0430\u043a \u0438 \u0432\u0441\u0435 GET \u0437\u0430\u043f\u0440\u043e\u0441\u044b) \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u0442\u0435\u043b\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442.\u00a0\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430\u00a0<code>req_body_*()<\/code> \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043a \u0442\u0435\u043b\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.\u00a0\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u00a0<code>req_body_json()<\/code> \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0432\u0438\u0434\u0435 JSON \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b:<\/p>\n<pre><code class=\"r\">req %>%  req_body_json(list(x = 1, y = \"a\")) %>%   req_dry_run() #> POST \/get HTTP\/1.1 #> Host: httpbin.org #> User-Agent: httr2\/0.1.1 r-curl\/4.3.2 libcurl\/7.64.1 #> Accept: *\/* #> Accept-Encoding: deflate, gzip #> Content-Type: application\/json #> Content-Length: 15 #>  #> {\"x\":1,\"y\":\"a\"}<\/code><\/pre>\n<p>\u0427\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c?<\/p>\n<ul>\n<li>\n<p>\u041c\u0435\u0442\u043e\u0434 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u0441 GET \u043d\u0430 POST.\u00a0POST &#8212; \u044d\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.\u00a0\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u00a0<code>req_method()<\/code> \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041a \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0434\u0432\u0430 \u043d\u043e\u0432\u044b\u0445 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430:\u00a0<code>Content-Type<\/code> \u0438\u00a0<code>Content-Length<\/code>.\u00a0\u041e\u043d\u0438 \u0441\u043e\u043e\u0431\u0449\u0430\u044e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0443, \u043a\u0430\u043a \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043b\u043e &#8212; \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e JSON \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 15 \u0431\u0430\u0439\u0442.<\/p>\n<\/li>\n<li>\n<p>\u0423 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0435\u0441\u0442\u044c \u0442\u0435\u043b\u043e, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0438\u0437 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e JSON.<\/p>\n<\/li>\n<\/ul>\n<p>\u0420\u0430\u0437\u043d\u044b\u0435 API \u043c\u043e\u0433\u0443\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 \u0442\u0435\u043b\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <code>httr2<\/code> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432.\u00a0\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,\u00a0<code>req_body_form()<\/code> \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0432 \u0432\u0438\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0439 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u043c \u0444\u043e\u0440\u043c\u044b:<\/p>\n<pre><code class=\"r\">req %>%  req_body_form(list(x = \"1\", y = \"a\")) %>%   req_dry_run() #> POST \/get HTTP\/1.1 #> Host: httpbin.org #> User-Agent: httr2\/0.1.1 r-curl\/4.3.2 libcurl\/7.64.1 #> Accept: *\/* #> Accept-Encoding: deflate, gzip #> Content-Type: application\/x-www-form-urlencoded #> Content-Length: 7 #>  #> x=1&amp;y=a<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043e\u0431\u044a\u0451\u043c\u0430 \u0438\u043b\u0438 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>req_body_multipart()<\/code>:<\/p>\n<pre><code class=\"r\">req %>%  req_body_multipart(list(x = \"1\", y = \"a\")) %>%   req_dry_run() #> POST \/get HTTP\/1.1 #> Host: httpbin.org #> User-Agent: httr2\/0.1.1 r-curl\/4.3.2 libcurl\/7.64.1 #> Accept: *\/* #> Accept-Encoding: deflate, gzip #> Content-Length: 228 #> Content-Type: multipart\/form-data; boundary=------------------------cc86fca72508d8b0 #>  #> --------------------------cc86fca72508d8b0 #> Content-Disposition: form-data; name=\"x\" #>  #> 1 #> --------------------------cc86fca72508d8b0 #> Content-Disposition: form-data; name=\"y\" #>  #> a #> --------------------------cc86fca72508d8b0--<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u043e\u0440\u043c\u0435, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u00a0<code>req_body_raw()<\/code> \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0435\u043b\u043e \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0442\u0438\u043f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435\u00a0<code>Content-Type<\/code>.<\/p>\n<p><a class=\"anchor\" name=\"get_response\" id=\"get_response\"><\/a><\/p>\n<h2>\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0442\u0432\u0435\u0442\u0430<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u00a0<code>req_perform()<\/code>:<\/p>\n<pre><code class=\"r\">req &lt;- request(\"https:\/\/httpbin.org\/json\") resp &lt;- req %>% req_perform() resp #> &lt;httr2_response> #> GET https:\/\/httpbin.org\/json #> Status: 200 OK #> Content-Type: application\/json #> Body: In memory (429 bytes)<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>resp_raw()<\/code>:<\/p>\n<pre><code class=\"r\">resp %>% resp_raw() #> HTTP\/1.1 200 OK #> date: Mon, 27 Sep 2021 20:40:32 GMT #> content-type: application\/json #> content-length: 429 #> server: gunicorn\/19.9.0 #> access-control-allow-origin: * #> access-control-allow-credentials: true #>  #> { #> \"slideshow\": { #> \"author\": \"Yours Truly\",  #> \"date\": \"date of publication\",  #> \"slides\": [ #> { #> \"title\": \"Wake up to WonderWidgets!\",  #> \"type\": \"all\" #> },  #> { #> \"items\": [ #> \"Why &lt;em>WonderWidgets&lt;\/em> are great\",  #> \"Who &lt;em>buys&lt;\/em> WonderWidgets\" #> ],  #> \"title\": \"Overview\",  #> \"type\": \"all\" #> } #> ],  #> \"title\": \"Sample Slide Show\" #> } #> }<\/code><\/pre>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 HTTP \u043e\u0442\u0432\u0435\u0442\u0430 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e HTTP \u0438 \u043a\u043e\u0434 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c (\u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e) \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0435\u0433\u043e \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435.\u00a0\u0417\u0430\u0442\u0435\u043c \u0438\u0434\u0443\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0442\u0435\u043b\u043e \u043e\u0442\u0432\u0435\u0442\u0430.\u00a0\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0442\u0435\u043b\u043e.<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430\u00a0<code>resp_()<\/code>:<\/p>\n<ul>\n<li>\n<p><code>resp_status()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u0434 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438\u00a0<code>resp_status_desc()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"r\">resp %>% resp_status() #> [1] 200 resp %>% resp_status_desc() #> [1] \"OK\"<\/code><\/pre>\n<ul>\n<li>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0432\u0441\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f\u00a0<code>resp_headers()<\/code> \u0438\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<code>resp_header()<\/code>:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"r\">resp %>% resp_headers() #> &lt;httr2_headers> #> date: Mon, 27 Sep 2021 20:40:32 GMT #> content-type: application\/json #> content-length: 429 #> server: gunicorn\/19.9.0 #> access-control-allow-origin: * #> access-control-allow-credentials: true resp %>% resp_header(\"Content-Length\") #> [1] \"429\"<\/code><\/pre>\n<p>\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u043d\u0435\u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b \u043a \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443:<\/p>\n<pre><code class=\"r\">resp %>% resp_header(\"ConTEnT-LeNgTH\") #> [1] \"429\"<\/code><\/pre>\n<p>\u0422\u0435\u043b\u043e \u043e\u0442\u0432\u0435\u0442\u0430, \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 API \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u0445. \u0414\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u043b\u0430 \u043e\u0442\u0432\u0435\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430 \u00a0<code>resp_body_*()<\/code>. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043e\u0442\u0432\u0435\u0442 \u0432 \u0432\u0438\u0434\u0435 JSON \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0435\u0433\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>resp_body_json()<\/code>:<\/p>\n<pre><code class=\"r\">resp %>% resp_body_json() %>% str() #> List of 1 #> $ slideshow:List of 4 #> ..$ author: chr \"Yours Truly\" #> ..$ date : chr \"date of publication\" #> ..$ slides:List of 2 #> .. ..$ :List of 2 #> .. .. ..$ title: chr \"Wake up to WonderWidgets!\" #> .. .. ..$ type : chr \"all\" #> .. ..$ :List of 3 #> .. .. ..$ items:List of 2 #> .. .. .. ..$ : chr \"Why &lt;em>WonderWidgets&lt;\/em> are great\" #> .. .. .. ..$ : chr \"Who &lt;em>buys&lt;\/em> WonderWidgets\" #> .. .. ..$ title: chr \"Overview\" #> .. .. ..$ type : chr \"all\" #> ..$ title : chr \"Sample Slide Show\"<\/code><\/pre>\n<p>\u041e\u0442\u0432\u0435\u0442\u044b \u0441 \u043a\u043e\u0434\u0430\u043c\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f <code>4xx<\/code> \u0438 <code>5xx<\/code> \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438 HTTP.\u00a0<code>httr2<\/code> \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0438\u0445 \u0432 \u043e\u0448\u0438\u0431\u043a\u0438 R:<\/p>\n<pre><code class=\"r\">request(\"https:\/\/httpbin.org\/status\/404\") %>% req_perform() #> Error: HTTP 404 Not Found. request(\"https:\/\/httpbin.org\/status\/500\") %>% req_perform() #> Error: HTTP 500 Internal Server Error.<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u0432\u0430\u0436\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 <code>httr<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b \u044f\u0432\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430\u00a0<code>httr::stop_for_status()<\/code> \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043e\u043a HTTP \u0432 \u043e\u0448\u0438\u0431\u043a\u0438 R.\u00a0\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044e <code>httr<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<code>req_error(req, is_error = ~ FALSE)<\/code>.<\/p>\n<p><a class=\"anchor\" name=\"request_process\" id=\"request_process\"><\/a><\/p>\n<h2>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/h2>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435\u00a0<code>req_<\/code> \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043d\u0430 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441, \u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0431\u0449\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0442\u0432\u0435\u0442\u0430.\u00a0\u041a \u043d\u0438\u043c \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f:<\/p>\n<ul>\n<li>\n<p><code>req_cache()<\/code>\u00a0\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u0438\u0445 \u043e\u0442\u0432\u0435\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443, \u0435\u0441\u043b\u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c, \u0438 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0442\u0435 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/p>\n<\/li>\n<li>\n<p><code>req_throttle()<\/code>\u00a0\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u0430\u0443\u0437\u0443 \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u043d\u043e\u0433\u0438\u0435 API \u0438\u043c\u0435\u044e\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<\/li>\n<li>\n<p><code>req_retry()<\/code>\u00a0\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u043f\u043e\u043f\u044b\u0442\u043e\u043a \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0431\u043e\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0438 HTTP \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0430\u0443\u0437\u044b.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0441\u043c. \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 API \u0432\u00a0<code>vignette(\"wrapping-apis.Rmd\")<\/code>.<\/p>\n<p><a class=\"anchor\" name=\"from_author\" id=\"from_author\"><\/a><\/p>\n<h2>\u041e\u0442 \u0430\u0432\u0442\u043e\u0440\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430<\/h2>\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043f\u0430\u043a\u0435\u0442\u0430 <code>httr2<\/code> \u0431\u044b\u043b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0435\u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d, \u043e\u043d \u0434\u0430\u0451\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u0438 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440. \u041a \u0442\u043e\u043c\u0443 \u0434\u0430\u0451\u0442 \u0432\u0430\u043c \u0433\u0438\u0431\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043f\u0430\u0443\u0437\u0443 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438, \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<p>\u0411\u0443\u0434\u0443 \u0440\u0430\u0434 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c \u043f\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043a \u043f\u043e\u0441\u0442\u0443 \u0438\u043b\u0438 \u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u0445, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0430\u0441 \u0441\u0440\u0435\u0434\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432 \u0441\u0432\u043e\u0438\u0445 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0432 <a href=\"https:\/\/t.me\/R4marketing\" rel=\"noopener noreferrer nofollow\">telegram<\/a> \u0438 <a href=\"https:\/\/www.youtube.com\/R4marketing\/?sub_confirmation=1\" rel=\"noopener noreferrer nofollow\">youtube<\/a>. <\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/594855\/\"> https:\/\/habr.com\/ru\/post\/594855\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0426\u0435\u043b\u044c \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 &#8212; \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u043e\u0441\u043d\u043e\u0432\u044b <code>httr2<\/code>.\u00a0<\/p>\n<p><code>httr2<\/code> &#8212; \u043f\u0435\u0440\u0435\u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u0430 <code>httr<\/code>, \u0442.\u0435. \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 R.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c\u0438 HTTP-\u043e\u0442\u0432\u0435\u0442\u0430\u043c\u0438.\u00a0<code>httr2<\/code> \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u0434\u043b\u044f \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c HTTP, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043e\u0431\u044a\u044f\u0441\u043d\u044e \u043f\u043e \u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f.\u00a0\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u044f \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u0442\u0430\u0442\u044c\u0451\u0439 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Overview\" rel=\"noopener noreferrer nofollow\">&#171;An overview of HTTP&#187;<\/a> \u043e\u0442 MDN.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c <code>httr2<\/code>.<\/p>\n<pre><code class=\"r\">install.packages(\"httr2\") library(httr2)<\/code><\/pre>\n<h2>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435<\/h2>\n<p><em>\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442\u0435\u0441\u044c \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u0430\u043c \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u043c\u043e\u0438\u00a0<\/em><a href=\"https:\/\/t.me\/R4marketing\" rel=\"noopener noreferrer nofollow\"><em>telegram<\/em><\/a><em>\u00a0\u0438\u00a0<\/em><a href=\"https:\/\/www.youtube.com\/R4marketing\/?sub_confirmation=1\" rel=\"noopener noreferrer nofollow\"><em>youtube<\/em><\/a><em>\u00a0\u043a\u0430\u043d\u0430\u043b\u044b. \u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u044b \u044f\u0437\u044b\u043a\u0443 R.<\/em><\/p>\n<ol>\n<li>\n<p><a href=\"#create_request\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#get_response\" rel=\"noopener noreferrer nofollow\">\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0442\u0432\u0435\u0442\u0430<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#request_process\" rel=\"noopener noreferrer nofollow\">\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#from_author\" rel=\"noopener noreferrer nofollow\">\u041e\u0442 \u0430\u0432\u0442\u043e\u0440\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430<\/a><\/p>\n<\/li>\n<\/ol>\n<p><a class=\"anchor\" name=\"create_request\" id=\"create_request\"><\/a><\/p>\n<h2>\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/h2>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 <code>httr2<\/code> \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u042d\u0442\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u0430 <code>httr<\/code>, \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0432\u044b \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0438 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439: \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u0438 \u0435\u0433\u043e, \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u0438 \u043e\u0442\u0432\u0435\u0442. <code>httr2<\/code> \u0438\u043c\u0435\u0435\u0442 \u044f\u0432\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e URL:<\/p>\n<pre><code class=\"r\">req &lt;- request(\"https:\/\/httpbin.org\/get\") req #> &lt;httr2_request> #> GET https:\/\/httpbin.org\/get #> Body: empty<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e:<\/p>\n<pre><code class=\"r\">req %>% req_dry_run() #> GET \/get HTTP\/1.1 #> Host: httpbin.org #> User-Agent: httr2\/0.1.1 r-curl\/4.3.2 libcurl\/7.64.1 #> Accept: *\/* #> Accept-Encoding: deflate, gzip<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u0440\u0438 \u0432\u0430\u0436\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/p>\n<ul>\n<li>\n<p>HTTP\u00a0<strong>\u043c\u0435\u0442\u043e\u0434<\/strong>, \u0442.\u0435. \u0433\u043b\u0430\u0433\u043e\u043b,\u00a0\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0443,\u00a0\u043a\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441.\u00a0\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 GET, \u0441\u0430\u043c\u044b\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439, \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c\u00a0<em>\u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c<\/em>\u00a0\u0440\u0435\u0441\u0443\u0440\u0441 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.\u00a0\u0414\u0440\u0443\u0433\u0438\u0435 \u0442\u0430\u043a \u0436\u0435 \u0435\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 HTTP \u043c\u0435\u0442\u043e\u0434\u044b: POST, \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u0430, PUT, \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u0430, \u0438 DELETE, \u0434\u043b\u044f \u0435\u0433\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0443\u0442\u044c<\/strong>, URL \u0430\u0434\u0440\u0435\u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437: \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 (<code>http<\/code>\u0438\u043b\u0438\u00a0<code>https<\/code>), \u0445\u043e\u0441\u0442\u0430 (<code>httpbin.org<\/code>), \u0438 \u043f\u043e\u0440\u0442\u0430 (\u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f).<\/p>\n<\/li>\n<li>\n<p>\u0412\u0435\u0440\u0441\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 HTTP.\u00a0\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043d\u0430\u043c \u043d\u0435 \u0432\u0430\u0436\u043d\u0430, \u0442.\u043a. \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0438\u0434\u0451\u0442 \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043d\u0438\u0437\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0438\u0434\u0443\u0442\u00a0<strong>\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438<\/strong>\u00a0\u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u0445 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u0432 \u0432\u0438\u0434\u0435 \u043f\u0430\u0440 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u043a\u043e\u043c\u00a0<code>:<\/code>.\u00a0\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0431\u044b\u043b\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b <code>httr2<\/code>, \u043d\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0438\u0445 \u0438\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<code>req_headers()<\/code>:<\/p>\n<pre><code class=\"r\">req %>%  req_headers(  Name = \"Hadley\",   `Shoe-Size` = \"11\",   Accept = \"application\/json\"  ) %>%   req_dry_run() #> GET \/get HTTP\/1.1 #> Host: httpbin.org #> User-Agent: httr2\/0.1.1 r-curl\/4.3.2 libcurl\/7.64.1 #> Accept-Encoding: deflate, gzip #> Name: Hadley #> Shoe-Size: 11 #> Accept: application\/json<\/code><\/pre>\n<p>\u0418\u043c\u0435\u043d\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u043d\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b \u043a \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443, \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044e\u0442 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0438\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438.<\/p>\n<p>\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043b\u0435\u0434\u0443\u0435\u0442\u00a0<strong>\u0442\u0435\u043b\u043e<\/strong>\u00a0\u0437\u0430\u043f\u0440\u043e\u0441\u0430.\u00a0\u041f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b (\u043a\u0430\u043a \u0438 \u0432\u0441\u0435 GET \u0437\u0430\u043f\u0440\u043e\u0441\u044b) \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u0442\u0435\u043b\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442.\u00a0\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430\u00a0<code>req_body_*()<\/code> \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043a \u0442\u0435\u043b\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.\u00a0\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u00a0<code>req_body_json()<\/code> \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0432\u0438\u0434\u0435 JSON \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b:<\/p>\n<pre><code class=\"r\">req %>%  req_body_json(list(x = 1, y = \"a\")) %>%   req_dry_run() #> POST \/get HTTP\/1.1 #> Host: httpbin.org #> User-Agent: httr2\/0.1.1 r-curl\/4.3.2 libcurl\/7.64.1 #> Accept: *\/* #> Accept-Encoding: deflate, gzip #> Content-Type: application\/json #> Content-Length: 15 #>  #> {\"x\":1,\"y\":\"a\"}<\/code><\/pre>\n<p>\u0427\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c?<\/p>\n<ul>\n<li>\n<p>\u041c\u0435\u0442\u043e\u0434 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u0441 GET \u043d\u0430 POST.\u00a0POST &#8212; \u044d\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.\u00a0\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u00a0<code>req_method()<\/code> \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041a \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0434\u0432\u0430 \u043d\u043e\u0432\u044b\u0445 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430:\u00a0<code>Content-Type<\/code> \u0438\u00a0<code>Content-Length<\/code>.\u00a0\u041e\u043d\u0438 \u0441\u043e\u043e\u0431\u0449\u0430\u044e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0443, \u043a\u0430\u043a \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043b\u043e &#8212; \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e JSON \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 15 \u0431\u0430\u0439\u0442.<\/p>\n<\/li>\n<li>\n<p>\u0423 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0435\u0441\u0442\u044c \u0442\u0435\u043b\u043e, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0438\u0437 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e JSON.<\/p>\n<\/li>\n<\/ul>\n<p>\u0420\u0430\u0437\u043d\u044b\u0435 API \u043c\u043e\u0433\u0443\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 \u0442\u0435\u043b\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <code>httr2<\/code> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432.\u00a0\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,\u00a0<code>req_body_form()<\/code> \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0432 \u0432\u0438\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0439 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u043c \u0444\u043e\u0440\u043c\u044b:<\/p>\n<pre><code class=\"r\">req %>%  req_body_form(list(x = \"1\", y = \"a\")) %>%   req_dry_run() #> POST \/get HTTP\/1.1 #> Host: httpbin.org #> User-Agent: httr2\/0.1.1 r-curl\/4.3.2 libcurl\/7.64.1 #> Accept: *\/* #> Accept-Encoding: deflate, gzip #> Content-Type: application\/x-www-form-urlencoded #> Content-Length: 7 #>  #> x=1&amp;y=a<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043e\u0431\u044a\u0451\u043c\u0430 \u0438\u043b\u0438 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>req_body_multipart()<\/code>:<\/p>\n<pre><code class=\"r\">req %>%  req_body_multipart(list(x = \"1\", y = \"a\")) %>%   req_dry_run() #> POST \/get HTTP\/1.1 #> Host: httpbin.org #> User-Agent: httr2\/0.1.1 r-curl\/4.3.2 libcurl\/7.64.1 #> Accept: *\/* #> Accept-Encoding: deflate, gzip #> Content-Length: 228 #> Content-Type: multipart\/form-data; boundary=------------------------cc86fca72508d8b0 #>  #> --------------------------cc86fca72508d8b0 #> Content-Disposition: form-data; name=\"x\" #>  #> 1 #> --------------------------cc86fca72508d8b0 #> Content-Disposition: form-data; name=\"y\" #>  #> a #> --------------------------cc86fca72508d8b0--<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u043e\u0440\u043c\u0435, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u00a0<code>req_body_raw()<\/code> \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0435\u043b\u043e \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0442\u0438\u043f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435\u00a0<code>Content-Type<\/code>.<\/p>\n<p><a class=\"anchor\" name=\"get_response\" id=\"get_response\"><\/a><\/p>\n<h2>\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0442\u0432\u0435\u0442\u0430<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u00a0<code>req_perform()<\/code>:<\/p>\n<pre><code class=\"r\">req &lt;- request(\"https:\/\/httpbin.org\/json\") resp &lt;- req %>% req_perform() resp #> &lt;httr2_response> #> GET https:\/\/httpbin.org\/json #> Status: 200 OK #> Content-Type: application\/json #> Body: In memory (429 bytes)<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>resp_raw()<\/code>:<\/p>\n<pre><code class=\"r\">resp %>% resp_raw() #> HTTP\/1.1 200 OK #> date: Mon, 27 Sep 2021 20:40:32 GMT #> content-type: application\/json #> content-length: 429 #> server: gunicorn\/19.9.0 #> access-control-allow-origin: * #> access-control-allow-credentials: true #>  #> { #> \"slideshow\": { #> \"author\": \"Yours Truly\",  #> \"date\": \"date of publication\",  #> \"slides\": [ #> { #> \"title\": \"Wake up to WonderWidgets!\",  #> \"type\": \"all\" #> },  #> { #> \"items\": [ #> \"Why &lt;em>WonderWidgets&lt;\/em> are great\",  #> \"Who &lt;em>buys&lt;\/em> WonderWidgets\" #> ],  #> \"title\": \"Overview\",  #> \"type\": \"all\" #> } #> ],  #> \"title\": \"Sample Slide Show\" #> } #> }<\/code><\/pre>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 HTTP \u043e\u0442\u0432\u0435\u0442\u0430 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e HTTP \u0438 \u043a\u043e\u0434 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c (\u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e) \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0435\u0433\u043e \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435.\u00a0\u0417\u0430\u0442\u0435\u043c \u0438\u0434\u0443\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0442\u0435\u043b\u043e \u043e\u0442\u0432\u0435\u0442\u0430.\u00a0\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0442\u0435\u043b\u043e.<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430\u00a0<code>resp_()<\/code>:<\/p>\n<ul>\n<li>\n<p><code>resp_status()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u0434 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438\u00a0<code>resp_status_desc()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"r\">resp %>% resp_status() #> [1] 200 resp %>% resp_status_desc() #> [1] \"OK\"<\/code><\/pre>\n<ul>\n<li>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0432\u0441\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f\u00a0<code>resp_headers()<\/code> \u0438\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<code>resp_header()<\/code>:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"r\">resp %>% resp_headers() #> &lt;httr2_headers> #> date: Mon, 27 Sep 2021 20:40:32 GMT #> content-type: application\/json #> content-length: 429 #> server: gunicorn\/19.9.0 #> access-control-allow-origin: * #> access-control-allow-credentials: true resp %>% resp_header(\"Content-Length\") #> [1] \"429\"<\/code><\/pre>\n<p>\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u043d\u0435\u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b \u043a \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443:<\/p>\n<pre><code class=\"r\">resp %>% resp_header(\"ConTEnT-LeNgTH\") #> [1] \"429\"<\/code><\/pre>\n<p>\u0422\u0435\u043b\u043e \u043e\u0442\u0432\u0435\u0442\u0430, \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 API \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u0445. \u0414\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u043b\u0430 \u043e\u0442\u0432\u0435\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430 \u00a0<code>resp_body_*()<\/code>. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043e\u0442\u0432\u0435\u0442 \u0432 \u0432\u0438\u0434\u0435 JSON \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0435\u0433\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>resp_body_json()<\/code>:<\/p>\n<pre><code class=\"r\">resp %>% resp_body_json() %>% str() #> List of 1 #> $ slideshow:List of 4 #> ..$ author: chr \"Yours Truly\" #> ..$ date : chr \"date of publication\" #> ..$ slides:List of 2 #> .. ..$ :List of 2 #> .. .. ..$ title: chr \"Wake up to WonderWidgets!\" #> .. .. ..$ type : chr \"all\" #> .. ..$ :List of 3 #> .. .. ..$ items:List of 2 #> .. .. .. ..$ : chr \"Why &lt;em>WonderWidgets&lt;\/em> are great\" #> .. .. .. ..$ : chr \"Who &lt;em>buys&lt;\/em> WonderWidgets\" #> .. .. ..$ title: chr \"Overview\" #> .. .. ..$ type : chr \"all\" #> ..$ title : chr \"Sample Slide Show\"<\/code><\/pre>\n<p>\u041e\u0442\u0432\u0435\u0442\u044b \u0441 \u043a\u043e\u0434\u0430\u043c\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f <code>4xx<\/code> \u0438 <code>5xx<\/code> \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438 HTTP.\u00a0<code>httr2<\/code> \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0438\u0445 \u0432 \u043e\u0448\u0438\u0431\u043a\u0438 R:<\/p>\n<pre><code class=\"r\">request(\"https:\/\/httpbin.org\/status\/404\") %>% req_perform() #> Error: HTTP 404 Not Found. request(\"https:\/\/httpbin.org\/status\/500\") %>% req_perform() #> Error: HTTP 500 Internal Server Error.<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u0432\u0430\u0436\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 <code>httr<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b \u044f\u0432\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430\u00a0<code>httr::stop_for_status()<\/code> \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043e\u043a HTTP \u0432 \u043e\u0448\u0438\u0431\u043a\u0438 R.\u00a0\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044e <code>httr<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<code>req_error(req, is_error = ~ FALSE)<\/code>.<\/p>\n<p><a class=\"anchor\" name=\"request_process\" id=\"request_process\"><\/a><\/p>\n<h2>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/h2>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435\u00a0<code>req_<\/code> \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043d\u0430 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441, \u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0431\u0449\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0442\u0432\u0435\u0442\u0430.\u00a0\u041a \u043d\u0438\u043c \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f:<\/p>\n<ul>\n<li>\n<p><code>req_cache()<\/code>\u00a0\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u0438\u0445 \u043e\u0442\u0432\u0435\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443, \u0435\u0441\u043b\u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c, \u0438 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0442\u0435 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/p>\n<\/li>\n<li>\n<p><code>req_throttle()<\/code>\u00a0\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u0430\u0443\u0437\u0443 \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u043d\u043e\u0433\u0438\u0435 API \u0438\u043c\u0435\u044e\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<\/li>\n<li>\n<p><code>req_retry()<\/code>\u00a0\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u043f\u043e\u043f\u044b\u0442\u043e\u043a \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0431\u043e\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0438 HTTP \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0430\u0443\u0437\u044b.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0441\u043c. \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 API \u0432\u00a0<code>vignette(\"wrapping-apis.Rmd\")<\/code>.<\/p>\n<p><a class=\"anchor\" name=\"from_author\" id=\"from_author\"><\/a><\/p>\n<h2>\u041e\u0442 \u0430\u0432\u0442\u043e\u0440\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430<\/h2>\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043f\u0430\u043a\u0435\u0442\u0430 <code>httr2<\/code> \u0431\u044b\u043b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0435\u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d, \u043e\u043d \u0434\u0430\u0451\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-329723","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/329723","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=329723"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/329723\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=329723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=329723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=329723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}