Code Monkey home page Code Monkey logo

vim-http's Introduction

CircleCI Powered by vital.vim

vim-http

Simple wrapper over curl and http syntax highlighting.

asciicast

Usage

Write a raw http request

GET http://httpbin.org/get HTTP/1.1
Host: httpbin.org
Accept: application/json

:Http will execute the request and display the response in a new buffer.

:Http! will execute the request as above and follow any redirects.

:HttpShowCurl displays the curl request that the plugin executes under the hood

:HttpShowRequest displays the internal object representing the request

:HttpClean will add Host and Content-Length headers

:HttpAuth will prompt for authorization credentials

Configuration

g:vim_http_clean_before_do if set to 1 (default) will clean a request before sending it to curl. Disable this by setting this global to 0

g:vim_http_additional_curl_args can be used to provide additional arguments to curl.

g:vim_http_split_vertically when set to 1 will split the window vertically on response rather than horizontally (the default).

g:vim_http_right_below when set to 1 split window will be open on the right (for vertical) or below (for horizontal).

g:vim_http_tempbuffer when set to 1 response buffers will overwrite each other instead of persisting forever.

Helper Methods

http#remove_header(header) removes all occurances of the given header in the current buffer.

http#set_header(header, value) sets the header to the given value in the current buffer, removes duplicates

Examples for your vimrc:

function! s:set_json_header() abort
  call http#set_header('Content-Type', 'application/json')
endfunction

function! s:clean_personal_stuff() abort
  call http#remove_header('Cookie')
  call http#remove_header('Accept')
  call http#remove_header('User-Agent')
  call http#remove_header('Accept-Language')
endfunction 

function! s:add_compression() abort
  call http#set_header('Accept-Encoding', 'deflate, gzip')
  let g:vim_http_additional_curl_args = '--compressed'
endfunction

command! JSON call s:set_json_header()
command! Anon call s:clean_personal_stuff()
command! Compression call s:add_compression()

vim-http's People

Contributors

bokwoon95 avatar nicwest avatar pbogut avatar shime avatar zhaozg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vim-http's Issues

Multiple requests in same file

I'm having some trouble using your plugin having multiple requests. It keeps modifying my files for some reason, it doesn't run the request under cursor, but the first one, then it ads Origin on line 1 and content-length where I have the cursor.
Sometimes it tries to run the whole buffer as one request.

What am I doing wrong?

###
GET http://localhost:8000/projects HTTP/1.1
Accept: application/json
Content-Type: application/json

###

POST http://localhost:8000/projects HTTP/1.1
Accept: application/json
Content-Type: application/json

{
    "name": "Learn rust3"
}

###

PATCH http://localhost:8000/projects/5 HTTP/1.1
Accept: application/json
Content-Type: application/json

{
  "name": "Learning rust 5"
}

Thanks!

Support multipart/form-data

Does this plugin only accept JSON requests? This was not clear in docs, and I also wasn't able to do form-data requests.

Support cookie authentication

Hi, great plugin, thanks. I want to know how can it support sending a cookie, let's say a JWT. I don't need manual auth, just pass the token. Thanks,

Add support for variables

In large requests, it is difficult to find places in the request body and insert appropriate values. It would be much more convenient if one can put variables instead and on the first few lines of the request file, set their values.

Something like ${date} notation inside the request where on the first line of the .http file I can write: #date=20200202

no URL specified

I use this plugin in Windows MSYS2 environment.
I get the following error when I execute :Http

curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information

Please give me some advice on what is wrong.

curl version is the following

$ curl -V
curl 7.63.0 (x86_64-w64-mingw32) libcurl/7.63.0 OpenSSL/1.1.1a (WinSSL) zlib/1.2.11 brotli/1.0.7 libidn2/2.1.0 libpsl/0.20.2 (+libidn2/
2.1.0) nghttp2/1.35.1
Release-Date: 2018-12-12
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL libz brotli TLS-SRP HTTP2 HTTPS-proxy MultiSSL PSL Metalink

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.