Skip to content

Commit 478800a

Browse files
author
diepm
committed
Update docs
1 parent f209c2a commit 478800a

File tree

2 files changed

+296
-146
lines changed

2 files changed

+296
-146
lines changed

README.md

Lines changed: 132 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,36 @@ merged with any global headers. Local headers overwrite global headers.
219219
POST /service
220220
var1=value
221221
222+
#### 5.2 Line-by-line Request Body
223+
224+
Since version 2.3.0, the request body can be specified on a line-by-line
225+
basis. It's useful for name-value pair services. Each line of the request
226+
body is passed to cURL using `--data` or `--data-urlencode` depending on
227+
the verb.
228+
229+
To enable,
230+
231+
let g:vrc_split_request_body = 1
232+
233+
or
234+
235+
let b:vrc_split_request_body = 1
236+
237+
Then the request body can be specified as
238+
239+
#
240+
# The following params in the request body will be
241+
# sent using `--data-urlencode`
242+
#
243+
http://localhost
244+
Content-Type: text/html; charset=UTF-8
245+
GET /service
246+
var1=value1
247+
var2=value2
248+
249+
This option won't take effect for `GET` request if the option
250+
`vrc_allow_get_request_body` is set.
251+
222252
### 6. Configuration
223253
224254
VRC supports a few configurable variables. Each of them can have a global or
@@ -231,43 +261,64 @@ or in Vim for the buffer scope by
231261
232262
let b:option_name = value
233263
234-
#### `vrc_trigger`
264+
#### `vrc_allow_get_request_body`
235265
236-
This option defines the trigger key. It's `<C-j>` by default. To remap the key,
266+
Allow GET request to have a request body or not. Default: 0.
237267
238-
let g:vrc_trigger = '<C-k>'
268+
If this option is set, `-X GET` is used and the request body is passed to
269+
cURL as a whole using `--data`.
239270
240-
#### `vrc_ssl_secure`
271+
This option is useful for such services as ElasticSearch.
241272
242-
This option tells cURL to check or not check for the SSL certificates. It's
243-
turned off by default. To enable,
273+
#
274+
# With vrc_allow_get_request_body = 1
275+
#
276+
http://localhost:9200
277+
Content-Type: application/json
244278
245-
let g:vrc_ssl_secure = 1
279+
GET /testindex/testtype/_search
280+
{
281+
"query": {
282+
"match": { "name": "FOO" }
283+
}
284+
}
246285
247-
#### `vrc_output_buffer_name`
286+
Be careful that when this option is enabled, the request body is always sent
287+
as a whole regardless of `vrc_split_request_body`.
248288
249-
This option sets the name for the output/display buffer. By default, it's set
250-
to `__REST_response__`. To assign a different name,
289+
#### `vrc_auto_format_response_enabled`
251290
252-
let g:vrc_output_buffer_name = '__NEW_NAME__'
291+
This option enables the automatic formatting of the response. It's enabled by
292+
default. To disable:
253293
254-
This option is useful in working with multiple VRC buffers where each one has
255-
its own output display. For this, the option can be set in the buffer scope as
294+
let g:vrc_auto_format_response_enabled = 0
256295
257-
let b:vrc_output_buffer_name = '__REST_1_OUTPUT__'
296+
If `vrc_include_response_header` is disabled, this option does nothing.
258297
259-
#### `vrc_header_content_type`
298+
#### `vrc_auto_format_response_patterns`
260299
261-
This option is to set the header content type of the request. It defaults to
262-
`application/json`. To set a different default content type,
300+
This option defines which external tools to use to auto-format the response
301+
body according to the Content-Type.
263302
264-
let g:vrc_header_content_type = 'application/x-www-form-urlencoded'
303+
The defaults are:
265304
266-
It can also be set in the buffer scope by
305+
let s:vrc_auto_format_response_patterns = {
306+
\ 'json': 'python -m json.tool',
307+
\ 'xml': 'xmllint --format -',
308+
\}
267309
268-
let b:vrc_header_content_type = 'application/json; charset=utf-8'
310+
Adjust the list by defining the global or buffer variable, like so:
269311
270-
If `Content-Type` is specified in the request block, it overrides this setting.
312+
let g:vrc_auto_format_response_patterns = {
313+
\ 'json': ''
314+
\ 'xml': 'tidy -xml -i -'
315+
\}
316+
317+
If `vrc_include_response_header` is disabled, this option does nothing.
318+
319+
#### `vrc_connect_timeout`
320+
321+
Corresponding to cUrl option `--connect-timeout`. Default: 10 seconds.
271322
272323
#### `vrc_cookie_jar`
273324
@@ -280,16 +331,11 @@ It can also be set in the buffer scope by
280331
281332
let b:vrc_cookie_jar = './jar'
282333
283-
#### `vrc_set_default_mapping`
284-
285-
This option is to enable/disable the trigger key mapping. It's enabled by
286-
default. To disable the mapping,
287-
288-
let g:vrc_set_default_mapping = 0
289-
290-
Once the mapping is disabled, the request block can be executed by
334+
#### `vrc_debug`
291335
292-
:call VrcQuery()
336+
This option enables the debug mode by adding the `-v` option to the *curl*
337+
command and also `echom` the command to the Vim console. It's turned off by
338+
default.
293339
294340
#### `vrc_follow_redirects`
295341
@@ -298,6 +344,19 @@ redirects. It's turned off by default. To enable
298344
299345
let g:vrc_follow_redirects = 1
300346
347+
#### `vrc_header_content_type`
348+
349+
This option is to set the header content type of the request. It defaults to
350+
`application/json`. To set a different default content type,
351+
352+
let g:vrc_header_content_type = 'application/x-www-form-urlencoded'
353+
354+
It can also be set in the buffer scope by
355+
356+
let b:vrc_header_content_type = 'application/json; charset=utf-8'
357+
358+
If `Content-Type` is specified in the request block, it overrides this setting.
359+
301360
#### `vrc_include_response_header`
302361
303362
This option enables the inclusion of the response header information mode by
@@ -312,35 +371,50 @@ If this option is disabled, the following options will not take effect.
312371
* `vrc_auto_format_response_patterns`
313372
* `vrc_syntax_highlight_response`
314373
315-
#### `vrc_auto_format_response_enabled`
374+
#### `vrc_max_time`
316375
317-
This option enables the automatic formatting of the response. It's enabled by
318-
default. To disable:
376+
Corresponding to cUrl option `--max-time`. Default: 60 seconds.
319377
320-
let g:vrc_auto_format_response_enabled = 0
378+
#### `vrc_output_buffer_name`
321379
322-
If `vrc_include_response_header` is disabled, this option does nothing.
380+
This option sets the name for the output/display buffer. By default, it's set
381+
to `__REST_response__`. To assign a different name,
323382
324-
#### `vrc_auto_format_response_patterns`
383+
let g:vrc_output_buffer_name = '__NEW_NAME__'
325384
326-
This option defines which external tools to use to auto-format the response
327-
body according to the Content-Type.
385+
This option is useful in working with multiple VRC buffers where each one has
386+
its own output display. For this, the option can be set in the buffer scope as
328387
329-
The defaults are:
388+
let b:vrc_output_buffer_name = '__REST_1_OUTPUT__'
330389
331-
let s:vrc_auto_format_response_patterns = {
332-
\ 'json': 'python -m json.tool',
333-
\ 'xml': 'xmllint --format -',
334-
\}
390+
#### `vrc_set_default_mapping`
335391
336-
Adjust the list by defining the global or buffer variable, like so:
392+
This option is to enable/disable the trigger key mapping. It's enabled by
393+
default. To disable the mapping,
337394
338-
let g:vrc_auto_format_response_patterns = {
339-
\ 'json': ''
340-
\ 'xml': 'tidy -xml -i -'
341-
\}
395+
let g:vrc_set_default_mapping = 0
342396
343-
If `vrc_include_response_header` is disabled, this option does nothing.
397+
Once the mapping is disabled, the request block can be executed by
398+
399+
:call VrcQuery()
400+
401+
#### `vrc_split_request_body`
402+
403+
Determine if the request body should be processed line by line. Default: 0.
404+
405+
If this option is set, each line of the request body is passed to cURL using
406+
either `--data` or `--data-urlencode` depending on the verb.
407+
408+
If the verb is `GET` and the option `vrc_allow_get_request_body` is enabled,
409+
this option doesn't take effect; the request body is always sent as a whole
410+
using `--data`.
411+
412+
#### `vrc_ssl_secure`
413+
414+
This option tells cURL to check or not check for the SSL certificates. It's
415+
turned off by default. To enable,
416+
417+
let g:vrc_ssl_secure = 1
344418
345419
#### `vrc_syntax_highlight_response`
346420
@@ -351,19 +425,11 @@ the Content-Type. It's enabled by default. To disable:
351425
352426
If `vrc_include_response_header` is disabled, this option does nothing.
353427
354-
#### `vrc_connect_timeout`
355-
356-
Corresponding to cUrl option `--connect-timeout`. Default: 10 seconds.
357-
358-
#### `vrc_max_time`
359-
360-
Corresponding to cUrl option `--max-time`. Default: 60 seconds.
428+
#### `vrc_trigger`
361429
362-
#### `vrc_debug`
430+
This option defines the trigger key. It's `<C-j>` by default. To remap the key,
363431
364-
This option enables the debug mode by adding the `-v` option to the *curl*
365-
command and also `echom` the command to the Vim console. It's turned off by
366-
default.
432+
let g:vrc_trigger = '<C-k>'
367433
368434
### 7. Tips 'n Tricks
369435
@@ -397,6 +463,7 @@ Thanks to the contributors (in alphabetical order)
397463
@jojoyuji
398464
@korin
399465
@mjakl
466+
@nathanaelkane
400467
@p1otr
401468
@rlisowski
402469
@sethtrain
@@ -406,6 +473,11 @@ Thanks to the contributors (in alphabetical order)
406473
407474
### 9. Changelog
408475
476+
#### 2.3.0 (2016-03-24)
477+
478+
* GET request can have request body.
479+
* Request body can be specified on a line-by-line basis.
480+
409481
#### 2.2.0 (2016-02-08)
410482
411483
* Add support for PATCH, OPTIONS, and TRACE.

0 commit comments

Comments
 (0)