Skip to content

Commit

Permalink
Merge pull request #27 from itchyny/http2
Browse files Browse the repository at this point in the history
Support HTTP/2 response
  • Loading branch information
mattn committed Jul 5, 2016
2 parents ca89bd5 + e012cd1 commit e3fa93f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions autoload/webapi/http.vim
Expand Up @@ -159,7 +159,7 @@ function! webapi#http#get(url, ...) abort
throw "require `curl` or `wget` command"
endif
if follow != 0
while res =~ '^HTTP/1.\d 3' || res =~ '^HTTP/1\.[01] [0-9]\{3} .\+\n\r\?\nHTTP/1\.[01] [0-9]\{3} .\+'
while res =~# '^HTTP/\%(1\.[01]\|2\%(\.0\)\?\) 3' || res =~# '^HTTP/1\.[01] [0-9]\{3} .\+\n\r\?\nHTTP/1\.[01] [0-9]\{3} .\+'
let pos = stridx(res, "\r\n\r\n")
if pos != -1
let res = strpart(res, pos+4)
Expand All @@ -177,7 +177,7 @@ function! webapi#http#get(url, ...) abort
let content = strpart(res, pos+2)
endif
let header = split(res[:pos-1], '\r\?\n')
let matched = matchlist(get(header, 0), '^HTTP/1\.\d\s\+\(\d\+\)\s\+\(.*\)')
let matched = matchlist(get(header, 0), '^HTTP/\%(1\.[01]\|2\%(\.0\)\?\)\s\+\(\d\+\)\s*\(.*\)')
if !empty(matched)
let [status, message] = matched[1 : 2]
call remove(header, 0)
Expand Down Expand Up @@ -240,7 +240,7 @@ function! webapi#http#post(url, ...) abort
endif
call delete(file)
if follow != 0
while res =~ '^HTTP/1.\d 3' || res =~ '^HTTP/1\.[01] [0-9]\{3} .\+\n\r\?\nHTTP/1\.[01] [0-9]\{3} .\+'
while res =~# '^HTTP/\%(1\.[01]\|2\%(\.0\)\?\) 3' || res =~# '^HTTP/1\.[01] [0-9]\{3} .\+\n\r\?\nHTTP/1\.[01] [0-9]\{3} .\+'
let pos = stridx(res, "\r\n\r\n")
if pos != -1
let res = strpart(res, pos+4)
Expand All @@ -258,7 +258,7 @@ function! webapi#http#post(url, ...) abort
let content = strpart(res, pos+2)
endif
let header = split(res[:pos-1], '\r\?\n')
let matched = matchlist(get(header, 0), '^HTTP/1\.\d\s\+\(\d\+\)\s\+\(.*\)')
let matched = matchlist(get(header, 0), '^HTTP/\%(1\.[01]\|2\%(\.0\)\?\)\s\+\(\d\+\)\s*\(.*\)')
if !empty(matched)
let [status, message] = matched[1 : 2]
call remove(header, 0)
Expand Down

0 comments on commit e3fa93f

Please sign in to comment.