超文本传输-http

描述

HTTP,父对象为ui,无子对象


事件

  • receive: 网络请求返回,事件函数定义:onReceive(url, statusCode), url为网络请求的URL地址,statusCode为网络返回状态码,
    • 200 表示OK成功, 301/302表示页面跳转,404表示页面没找到,500表示服务器错误
    • 3 表示找不到主机
    • 4 表示网络超时
    • 99 表示未知网络错误

属性

名称 功能说明 脚本例子
userAgent 用户代理 ui.form-name.http-name.userAgent='ExpOS/1.0' 设置用户代理字符串为'ExpOS/1.0'
autoRedirect 301或302自动跳转 ui.form-name.http-name.autoRedirect=true 设置自动跳转使能

方法

名称 功能说明 脚本例子
get(url) 发送http或https协议get请求 - url,请求的服务器URL地址 ui.form-name.http-name.get('https://www.baidu.com') 发送get请求百度
post(url) 发送http或https协议post请求 - url,请求的服务器URL地址 ui.form-name.http-name.post('https://www.baidu.com') 发送post请求百度
post(url, content) 发送http或https协议post请求 - url,请求的服务器URL地址 -content, post请求发送的数据内容 ui.form-name.http-name.post('https://www.baidu.com','abcd') 发送post请求百度,数据内容为'abcd'
read() 必须在onReceive(url, statusCode)方法中调用,读取当前url对应的服务器response内容 ui.form-name.http-name.read() 读取当前请求返回的response内容
header(name) 获取http服务端返回response的头内容 ui.form-name.http-name.header('Content-Type') 读取服务端的回复头'Content-Type'值
setHeader(name, value) 设置http请求头内容 ui.form-name.http-name.setHeader('Content-Type', 'application/json') 设置请求头的'content-type'值

results matching ""

    No results matching ""