Chrome请求出现Provisional headers are shown 解决

chrome 浏览器输入: chrome://net-internals/#events

查看事件追踪:

99529: URL_REQUEST
https://localhost:9000/uitestcase/upload.api
Start Time: 2018-12-12 16:27:28.502

t=4694 [st=0] +REQUEST_ALIVE  [dt=5]
               --> priority = "MEDIUM"
               --> url = "https://localhost:9000/uitestcase/upload.api"
t=4694 [st=0]    NETWORK_DELEGATE_BEFORE_URL_REQUEST  [dt=1]
t=4695 [st=1]   +URL_REQUEST_START_JOB  [dt=3]
                 --> load_flags = 17218 (BYPASS_CACHE | DO_NOT_SAVE_COOKIES | DO_NOT_SEND_AUTH_DATA | DO_NOT_SEND_COOKIES | MAYBE_USER_GESTURE)
                 --> method = "POST"
                 --> upload_id = "0"
                 --> url = "https://localhost:9000/uitestcase/upload.api"
t=4695 [st=1]     +NETWORK_DELEGATE_BEFORE_START_TRANSACTION  [dt=1]
t=4695 [st=1]        DELEGATE_INFO  [dt=1]
                     --> delegate_blocked_by = "扩展程序“Postman Interceptor”"
t=4696 [st=2]     -NETWORK_DELEGATE_BEFORE_START_TRANSACTION
t=4697 [st=3]      HTTP_CACHE_GET_BACKEND  [dt=0]
t=4697 [st=3]     +HTTP_STREAM_REQUEST  [dt=1]
t=4697 [st=3]        HTTP_STREAM_JOB_CONTROLLER_BOUND
                     --> source_dependency = 99530 (HTTP_STREAM_JOB_CONTROLLER)
t=4698 [st=4]        HTTP_STREAM_REQUEST_BOUND_TO_JOB
                     --> source_dependency = 99531 (HTTP_STREAM_JOB)
t=4698 [st=4]     -HTTP_STREAM_REQUEST
t=4698 [st=4]   -URL_REQUEST_START_JOB
                 --> net_error = -102 (ERR_CONNECTION_REFUSED)
t=4698 [st=4]    URL_REQUEST_DELEGATE_RESPONSE_STARTED  [dt=1]
t=4699 [st=5] -REQUEST_ALIVE
               --> net_error = -102 (ERR_CONNECTION_REFUSED)

image.png

101052: SOCKET
pm/ssl/localhost:9000
Start Time: 2018-12-12 16:34:00.788

t=7491 [st=0] +SOCKET_ALIVE  [dt=0]
               --> source_dependency = 101051 (TRANSPORT_CONNECT_JOB)
t=7491 [st=0]   +TCP_CONNECT  [dt=0]
                 --> address_list = ["[::1]:9000","127.0.0.1:9000"]
t=7491 [st=0]     +TCP_CONNECT_ATTEMPT  [dt=0]
                   --> address = "[::1]:9000"
t=7491 [st=0]     -TCP_CONNECT_ATTEMPT
                   --> os_error = 61
t=7491 [st=0]     +TCP_CONNECT_ATTEMPT  [dt=0]
                   --> address = "127.0.0.1:9000"
t=7491 [st=0]     -TCP_CONNECT_ATTEMPT
                   --> os_error = 61
t=7491 [st=0]   -TCP_CONNECT
                 --> net_error = -102 (ERR_CONNECTION_REFUSED)
t=7491 [st=0] -SOCKET_ALIVE
101047: URL_REQUEST
https://localhost:9000/uitestcase/upload.api
Start Time: 2018-12-12 16:34:00.786

t=7489 [st=0] +REQUEST_ALIVE  [dt=4]
               --> priority = "MEDIUM"
               --> url = "https://localhost:9000/uitestcase/upload.api"
t=7490 [st=1]    NETWORK_DELEGATE_BEFORE_URL_REQUEST  [dt=0]
t=7490 [st=1]   +URL_REQUEST_START_JOB  [dt=2]
                 --> load_flags = 17218 (BYPASS_CACHE | DO_NOT_SAVE_COOKIES | DO_NOT_SEND_AUTH_DATA | DO_NOT_SEND_COOKIES | MAYBE_USER_GESTURE)
                 --> method = "POST"
                 --> upload_id = "0"
                 --> url = "https://localhost:9000/uitestcase/upload.api"
t=7490 [st=1]      NETWORK_DELEGATE_BEFORE_START_TRANSACTION  [dt=0]
t=7490 [st=1]      HTTP_CACHE_GET_BACKEND  [dt=0]
t=7490 [st=1]     +HTTP_STREAM_REQUEST  [dt=2]
t=7490 [st=1]        HTTP_STREAM_JOB_CONTROLLER_BOUND
                     --> source_dependency = 101048 (HTTP_STREAM_JOB_CONTROLLER)
t=7492 [st=3]        HTTP_STREAM_REQUEST_BOUND_TO_JOB
                     --> source_dependency = 101049 (HTTP_STREAM_JOB)
t=7492 [st=3]     -HTTP_STREAM_REQUEST
t=7492 [st=3]   -URL_REQUEST_START_JOB
                 --> net_error = -102 (ERR_CONNECTION_REFUSED)
t=7492 [st=3]    URL_REQUEST_DELEGATE_RESPONSE_STARTED  [dt=0]
t=7493 [st=4] -REQUEST_ALIVE
               --> net_error = -102 (ERR_CONNECTION_REFUSED)

后来才发现是 Controller 的代码忘记添加 @ResponseBody

package com.alibaba.swork.info.web.controller.ui;


import com.alibaba.swork.info.common.bean.model.UiTestCase;
import com.alibaba.swork.info.common.mapper.UiTestCaseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

@RequestMapping("/uitestcase")
@Controller
public class UiTestCaseController {
    @Autowired
    UiTestCaseMapper uiTestCaseMapper;

    @RequestMapping(value = {"/upload.api"}, method = RequestMethod.POST)
    @ResponseBody
    public boolean upload(String name, String sideJson, String token) {
        UiTestCase uiTestCase = new UiTestCase();
        uiTestCase.setGmtCreate(new Date());
        uiTestCase.setGmtModified(new Date());
        uiTestCase.setIsDeleted(0);
        uiTestCase.setName(name);
        uiTestCase.setSideJson(sideJson);
        uiTestCase.setToken(token);
        try {
            uiTestCaseMapper.insert(uiTestCase);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    @RequestMapping(value = {"/get.api"}, method = RequestMethod.GET)
    @ResponseBody
    public String get(String token) {
        return token;
    }

}

还有,就是不要用 https, 得用 http.

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区