1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SWI-Prolog の http クライアントの使い方 (Post)

Last updated at Posted at 2020-02-28
http_post.pl
/* ------------------------------------------------------------------- */
/*
	http_post.pl

						Feb/28/2020
*/
/* ------------------------------------------------------------------- */
:- use_module(library(http/http_client)).

:- initialization main.
main() :-
	format('*** 開始 ***\n'),
	Url_in = 'https://httpbin.org/post',
	http_post(Url_in,form_data([ user = 'jiro',password = '123456']),
		Data, []),
	format(Data),
	format('*** 終了 ***\n'),
	halt.
/* ------------------------------------------------------------------- */

実行結果

$ swipl -f ./http_post.pl
*** 開始 ***
{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {
    "password": "123456", 
    "user": "jiro"
  }, 
  "headers": {
    "Content-Length": "243", 
    "Content-Type": "multipart/form-data; boundary=------1582874349.3074793518a5ea421823a9", 
    "Host": "httpbin.org", 
    "Mime-Version": "1.0", 
    "User-Agent": "SWI-Prolog", 
    "X-Amzn-Trace-Id": "Root=1-5e58beeb-4b81029675de664fb66721a9"
  }, 
  "json": null, 
  "origin": "153.233.38.78", 
  "url": "https://httpbin.org/post"
}
*** 終了 ***

確認したバージョン

$ swipl --version
SWI-Prolog version 9.0.4 for x86_64-linux
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?