-
Notifications
You must be signed in to change notification settings - Fork 64
Web.AsyncHTTP: Added Web.AsyncHTTP. #847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Web.HTTP, Web.AsyncHTTP, Web.HTTP.Core に分割していこう、 Vitalize に失敗するようになっていたのでドラフトに戻しました。 |
|
Vitalize に失敗する問題を修正したのでドラフトを解除しました。 |
tsuyoshicho
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikoto2000
確認できた改善点をコメントしました。
一部は修正必須と思うので(といってもtypo) Request changes にしました。
doc/vital/Web/AsyncHTTP.txt
Outdated
| This function requires one of the clients, "curl" or "wget". | ||
|
|
||
| Example: > | ||
| let s:AsyncHTP = vital#{plugin-name}#new().import('Web.AsyncHTTP') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let s:AsyncHTP = vital#{plugin-name}#new().import('Web.AsyncHTTP') | |
| let s:AsyncHTTP = vital#{plugin-name}#new().import('Web.AsyncHTTP') |
typo fix
doc/vital/Web/AsyncHTTP.txt
Outdated
| python *Vital.Web.AsyncHTTP-client-python* | ||
| "python" as "python3" or "python2" auto select. | ||
| (High priority for "python3".) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core で Python のファイル依存をはずしたりしてますが、こちらは利用できますか?
(CoreとPython利用の組み合せがどうなっているかを確認したい感じです)
もし、非同期との関係を考えて、サポートしないほうがいいのであれば、clientから外すのはアリと思いますので、記述を更新してもらえれば
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
client の実体は、 HTTP, AsyncHTTP それぞれに存在しています。 (同期・非同期で実装が変わるため、それぞれで定義)
そのため、 python への依存は HTTP, AsyncHTTP それぞれから行っています。
ですので、 Core から python への依存は無くても大丈夫です。
Linux でですが、以下コードもエラーなく動きます。
let s:AsyncHTTP = vital#vital#import('Web.AsyncHTTP')
function! s:user_cb(response) abort
echomsg a:response
" => Web.HTTP と同じ形式の辞書
endfunction
call s:AsyncHTTP.request({
\ 'url': 'https://example.com',
\ 'user_cb': function('s:user_cb'),
\ 'clients': ['python2'],
\ })
call s:AsyncHTTP.request({
\ 'url': 'https://example.com',
\ 'user_cb': function('s:user_cb'),
\ 'clients': ['python3'],
\ })| function! s:_vital_loaded(V) abort | ||
| let s:V = a:V | ||
| let s:Prelude = s:V.import('Prelude') | ||
| let s:HTTP = s:V.import('Web.HTTP') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この依存関係は削除して、利用している機能は Core に置き、それを HTTP/AsyncHTTP が利用するように改善したほうがいいかと
| if has_key(s:clients.curl.errcode(), retcode) | ||
| throw 'vital: Web.HTTP: ' . s:clients.curl.errcode()[retcode] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
せっかくのリファクタリングでもあるので
if s:clients.curl.errcode_has_key(retcode)
throw 'vital: Web.HTTP: ' . s:clients.curl.errcode(retcode)みたいなインタフェースにしてもいいかもしれませんね
errcode()が配列返すのがマストではないし、複数回利用するようなら、配列を初期化時にコピー相当でもいいので、
- コピーする
- 関数IFにする
のどちらかに寄せたほうがいいかなと
|
クライアントの指定方法を感知餓死していたため、 curl 以外の動作確認ができていない状態でした。 |
doc/vital/Web/AsyncHTTP.txt
Outdated
| parseHeader({headers}) *Vital.Web.HTTP.parseHeader()* | ||
| Parse {headers} list to a dictionary. | ||
| Duplicated fields are overwritten. | ||
|
|
||
| encodeURI({param}) *Vital.Web.HTTP.encodeURI()* | ||
| Encode params as URI query. | ||
|
|
||
| decodeURI({str}) *Vital.Web.HTTP.decodeURI()* | ||
| Decode string as URI params. | ||
|
|
||
| encodeURIComponent({str}) *Vital.Web.HTTP.encodeURIComponent()* | ||
| Encode param as URI components. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここらへん AsyncHTTP になってないため、タグ重複エラーしてるみたいです。
正式で出すにあたって、修正しておいてください。
….HTTP and Web.AsyncHTTP.
…TTP to Web.HTTP.Core.
…eb.HTTP and Web.AsyncHTTP to Web.HTTP.Core
75a63a6 to
d14a759
Compare
|
リカバリ力が足りず、一から細かく刻みつつ再実装してしまいました。 |
tsuyoshicho
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
見てみました
doc/vital/Web/AsyncHTTP.txt
Outdated
| CLIENT *Vital.Web.AsyncHTTP-client* | ||
|
|
||
| The following can be used. | ||
| (TODO: More document. Especially about limitation.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これは削除していいと思います。
また、Python系について、Pythonコマンド+スクリプトファイル+引数を AsyncProcess するという方法はなくはないので、一応TODOとしてPython3対応は将来予定として記載しておくのはどうでしょう?
(というか、そろそろ Python2 はもういい気がするな...w)
doc/vital/Web/AsyncHTTP.txt
Outdated
| "unixSocket" Default: (None) | ||
| Use --unix-sokect (only curl >= 7.40.0) | ||
|
|
||
| "user_cb" Default: (None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここだけスネークケースなのは微妙なので
| "user_cb" Default: (None) | |
| "userCallback" Default: (None) |
という引数にするのはどうでしょうか?
(そもそも Vim の記法としてどうかはあるけど)
| return result | ||
| endfunction | ||
|
|
||
| " public interface implements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
うえの build 系なども利用はあるので、そちらも public な気がします。
逆に Core 内に閉じる関数もなくない気がしますが... (あったら、やるなら s:_hoge 化?)
なお関数の記法がいろいろなのは、内部処理だったからでしょうね、そこはとりあえずそのままでもいいと思います。
8ad4e39 to
78617a8
Compare
…named according to the naming convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
おつかれさまです、安定したと思うので、詳細に見てみました。
ちょっと迷走しましたが、settings の client と、urlencode_char 、 依存関係のところは対処が必要と思います。
| let settings = { | ||
| \ 'method': 'GET', | ||
| \ 'headers': {}, | ||
| \ 'client': ['python', 'curl', 'wget', 'python3', 'python2'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
クライアントは各実装依存となったので、こちらで固定で設定するのではなく
- request で追加設定する
- 引数を追加して、引数から client 設定する
などのAPI設計にしたようが良いと思われます。
tsuyoshicho
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
追加指摘です。
一応helpは
https://github.com/vim-jp/vimdoc-ja-working/wiki/Guide
のフォーマッタ設定を使うといいのですが、現状ちゃんと書いてあるから問題はないといえばないです
やたら差分でますが、調整の範囲ではあるという...
doc/vital/Web/AsyncHTTP.txt
Outdated
| Maintainer: mattn <[email protected]> | ||
| thinca <[email protected]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここは自分にしてください
(元にしたのが Web.HTTP と書いてもいいかもです
82ad926 で対応いたしました。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Tsuyoshi CHO <[email protected]>
close #842