{"id":20708,"date":"2018-08-13T13:20:30","date_gmt":"2018-08-13T13:20:30","guid":{"rendered":"https:\/\/blog.jetbrains.com\/phpstorm\/?p=13039"},"modified":"2024-01-09T14:51:36","modified_gmt":"2024-01-09T13:51:36","slug":"http-client-enhancements","status":"publish","type":"phpstorm","link":"https:\/\/blog.jetbrains.com\/pt-br\/phpstorm\/2018\/08\/http-client-enhancements","title":{"rendered":"HTTP Client Enhancements"},"content":{"rendered":"<p>We continue improving the editor-based HTTP client, and PhpStorm 2018.2 brings several useful enhancements to it: you can now use environment variables inside the request body, apply code formatting to POST request bodies, and enjoy built-in Unicode support.<\/p>\n<p>Let&#8217;s take a closer look at these new features.<\/p>\n<p><!--more--><\/p>\n<h2>Support for environment variables in the request body<\/h2>\n<p>Environment variables let you parameterize certain parts of your request and substitute them with actual values when a request is executed. Previously, you could use variables for specifying the request&#8217;s host, port, and path, query parameter or value, and header value.<\/p>\n<p>In PhpStorm 2018.2, you can use variables for providing arbitrary values within the POST request body, too.<\/p>\n<p>The idea remains the same: declare your variables in an <em>env<\/em> file, and use the variables&#8217; placeholders enclosed between double curly braces either directly inside an HTTP file or in the external files that you\u2019ve included as the request body.<\/p>\n<p>When you execute the request, PhpStorm will prompt you to choose the environment holding the desired variable&#8217;s value:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-13040\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/07\/phpstorm-vars_in_body.png\" alt=\"vars_in_body\" width=\"785\" height=\"190\" \/><\/p>\n<h2>Formatting of POST request body<\/h2>\n<p>Another improvement you&#8217;ll notice when working with POST requests in PhpStorm 2018.2 is the ability to format the request&#8217;s body.<\/p>\n<p>To use it, simply invoke the <em>Code | Reformat code<\/em> action.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/07\/phpstorm-post_reformat_thumbnail.png\" alt=\"POST Body reformat\" width=\"734\" data-gif-src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/07\/phpstorm-post_reformat.gif\" \/><\/p>\n<p>The request&#8217;s body will be formatted in accordance with its <span class=\"lang:default decode:true crayon-inline \">Content-Type<\/span>\u00a0; if necessary, you can customize the code style for the corresponding language (for example, JSON or XML) under <em>Preferences | Editor | Code Style<\/em>.<\/p>\n<p>Please note that formatting HTTP requests that contain variables in the request body is currently not supported. To format such a request, press <em>Alt+Enter<\/em> and choose <em>Edit JSON\/XML<\/em> fragment. The fragment will open in a separate editor tab, from where you can format is as usual:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/07\/phpstorm-post_reformat_vars_thumbnail.png\" alt=\"POST Body reformat\" width=\"592\" data-gif-src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/07\/phpstorm-post_reformat_vars.gif\" \/><\/p>\n<h2>Decoding Unicode entities and character escapes in JSON replies<\/h2>\n<p>PhpStorm 2018.2. introduces the long-awaited support for Unicode symbols and character escape sequences in the HTTP response body.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-13046\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/07\/phpstorm-rest_encoding-2.png\" alt=\"rest_encoding-2\" width=\"642\" height=\"345\" \/><\/p>\n<p>With this support in place, you can inspect your responses in a natural manner, without looking into the characters table to find out what these magical letters actually translate to.<\/p>\n<p><em>Your JetBrains PhpStorm Team<\/em><br \/>\n<em>The Drive to Develop<\/em><\/p>\n","protected":false},"author":745,"featured_media":20714,"comment_status":"open","ping_status":"open","template":"","categories":[808,907],"tags":[602,743],"cross-post-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/phpstorm\/20708"}],"collection":[{"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/phpstorm"}],"about":[{"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/types\/phpstorm"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/users\/745"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/comments?post=20708"}],"version-history":[{"count":1,"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/phpstorm\/20708\/revisions"}],"predecessor-version":[{"id":431962,"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/phpstorm\/20708\/revisions\/431962"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/media\/20714"}],"wp:attachment":[{"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/media?parent=20708"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/categories?post=20708"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/tags?post=20708"},{"taxonomy":"cross-post-tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/cross-post-tag?post=20708"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}