@@ -219,6 +219,36 @@ merged with any global headers. Local headers overwrite global headers.
219
219
POST /service
220
220
var1=value
221
221
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
+
222
252
### 6. Configuration
223
253
224
254
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
231
261
232
262
let b:option_name = value
233
263
234
- #### `vrc_trigger `
264
+ #### `vrc_allow_get_request_body `
235
265
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.
237
267
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`.
239
270
240
- #### `vrc_ssl_secure`
271
+ This option is useful for such services as ElasticSearch.
241
272
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
244
278
245
- let g:vrc_ssl_secure = 1
279
+ GET /testindex/testtype/_search
280
+ {
281
+ "query": {
282
+ "match": { "name": "FOO" }
283
+ }
284
+ }
246
285
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`.
248
288
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`
251
290
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:
253
293
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
256
295
257
- let b:vrc_output_buffer_name = '__REST_1_OUTPUT__'
296
+ If `vrc_include_response_header` is disabled, this option does nothing.
258
297
259
- #### `vrc_header_content_type `
298
+ #### `vrc_auto_format_response_patterns `
260
299
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.
263
302
264
- let g:vrc_header_content_type = 'application/x-www-form-urlencoded'
303
+ The defaults are:
265
304
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
+ \}
267
309
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:
269
311
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.
271
322
272
323
#### `vrc_cookie_jar`
273
324
@@ -280,16 +331,11 @@ It can also be set in the buffer scope by
280
331
281
332
let b:vrc_cookie_jar = './jar'
282
333
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`
291
335
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.
293
339
294
340
#### `vrc_follow_redirects`
295
341
@@ -298,6 +344,19 @@ redirects. It's turned off by default. To enable
298
344
299
345
let g:vrc_follow_redirects = 1
300
346
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
+
301
360
#### `vrc_include_response_header`
302
361
303
362
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.
312
371
* `vrc_auto_format_response_patterns`
313
372
* `vrc_syntax_highlight_response`
314
373
315
- #### `vrc_auto_format_response_enabled `
374
+ #### `vrc_max_time `
316
375
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.
319
377
320
- let g:vrc_auto_format_response_enabled = 0
378
+ #### `vrc_output_buffer_name`
321
379
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,
323
382
324
- #### `vrc_auto_format_response_patterns`
383
+ let g:vrc_output_buffer_name = '__NEW_NAME__'
325
384
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
328
387
329
- The defaults are:
388
+ let b:vrc_output_buffer_name = '__REST_1_OUTPUT__'
330
389
331
- let s:vrc_auto_format_response_patterns = {
332
- \ 'json': 'python -m json.tool',
333
- \ 'xml': 'xmllint --format -',
334
- \}
390
+ #### `vrc_set_default_mapping`
335
391
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,
337
394
338
- let g:vrc_auto_format_response_patterns = {
339
- \ 'json': ''
340
- \ 'xml': 'tidy -xml -i -'
341
- \}
395
+ let g:vrc_set_default_mapping = 0
342
396
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
344
418
345
419
#### `vrc_syntax_highlight_response`
346
420
@@ -351,19 +425,11 @@ the Content-Type. It's enabled by default. To disable:
351
425
352
426
If `vrc_include_response_header` is disabled, this option does nothing.
353
427
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`
361
429
362
- #### `vrc_debug`
430
+ This option defines the trigger key. It's `<C-j>` by default. To remap the key,
363
431
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>'
367
433
368
434
### 7. Tips 'n Tricks
369
435
@@ -397,6 +463,7 @@ Thanks to the contributors (in alphabetical order)
397
463
@jojoyuji
398
464
@korin
399
465
@mjakl
466
+ @nathanaelkane
400
467
@p1otr
401
468
@rlisowski
402
469
@sethtrain
@@ -406,6 +473,11 @@ Thanks to the contributors (in alphabetical order)
406
473
407
474
### 9. Changelog
408
475
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
+
409
481
#### 2.2.0 (2016-02-08)
410
482
411
483
* Add support for PATCH, OPTIONS, and TRACE.
0 commit comments