1 Star 2 Fork 1

lqx / easy_http

 / 详情

简单的postxml ,返回数据在data里面 "data": "<request> <parameters> <email>test@test.com</email> <password>test</password>

已完成
创建于  
2021-08-25 11:27

简单的postxml ,返回数据在data里面 "data": " test@test.com test

func postxml() {
	body := "<request> <parameters> <email>test@test.com</email> <password>test</password> </parameters> </request>"

	client := &http.Client{}
	// build a new request, but not doing the POST yet
	req, err := http.NewRequest("POST", "http://httpbin.org/post", bytes.NewBuffer([]byte(body)))
	if err != nil {
		fmt.Println(err)
	}
	// you can then set the Header here
	// I think the content-type should be "application/xml" like json...
	req.Header.Add("Content-Type", "application/xml; charset=utf-8")
	// now POST it
	resp, err := client.Do(req)
	if err != nil {
		fmt.Println(err)
	}
	defer func() { _ = resp.Body.Close() }()

	content, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(content))

}

评论 (0)

ling66611 创建了任务
ling66611 关联仓库设置为lqx/easy_http
ling66611 修改了描述
ling66611 修改了描述
ling66611 修改了描述
lqx 任务状态待办的 修改为已完成
展开全部操作日志

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(1)
Go
1
https://gitee.com/lqxlucky/easy_http.git
git@gitee.com:lqxlucky/easy_http.git
lqxlucky
easy_http
easy_http

搜索帮助