Skip to content
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

Webview 如何查看header头信息 #52

Open
wuyunqiang opened this issue May 24, 2018 · 0 comments
Open

Webview 如何查看header头信息 #52

wuyunqiang opened this issue May 24, 2018 · 0 comments
Labels

Comments

@wuyunqiang
Copy link
Owner

有时候使用webview需要查看发送的header信息是否正确发送,一般我们都是和后台配合来检验的。其实我们也可以自己来检验,自己启动一个node作为服务端,然后连接本地的node服务来查看header信息。

var http = require('http');
var port = 9000;

function logRequest(request) {
    console.log("request headers: ", request.headers)
    console.log("Processing request for: ", request.url)
    console.log('Time',new Date().toString())

}

http.createServer(function(request, response) {
    response.writeHead(200, {"Content-Type": "text/html"});
    switch(request.url) {
        case "/":
            response.write("<html><body>Welcome<a href='/bye'>Bye</a></body></html>");
            logRequest(request)
            break;
        case "/bye":
            response.write("<html><body>Bye<a href='/'>Welcome</a></body></html>");
            logRequest(request)
            break;
        default:
            break;
    }
    response.end();
}).listen(port);

1:新建js文件取名server.js 然后复制上面的代码
2:打开命令行 node ../../server.js(server.js 路径)
3:修改webview 的source路径 添加header信息

 source={{uri: "http://localhost:9000/", headers: {name:"wuyunqiang",do:"testing"}}}

4:正常运行应用 打开webview页面 命令行显示如下
7C5797FE-CC3E-402F-971F-632DB13C067B.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant