Giter Site home page Giter Site logo

chatgpt-sse-hide-example's Introduction

chatgpt网页版看不到响应数据的原理及例子

如图: image image 是收到了响应数据的,有5.8 KB,但是 EventStream 却什么都没有。

一开始确实毫无头绪,但 @phodal 给出了思路,觉得是一些 http 的奇技淫巧,后来我顺着这个思路找下去发现不可能是 http 层面的问题,因为 spec 说明如果不是 event、data、id 或 retry 就会被浏览器丢掉,js 没有机会做*操作,我又翻了下 webkit 的源码 佐证了这一事实:浏览器并没有特殊实现,完全按照 spec 来的 image

最后经过研究发现其实服务端并没有进行什么*操作,只是浏览器端使用了server-sent-event(sse), 但是没有用标准的 EventSource,而是自己fetch,只不过 request header 加上了 'Accept': 'text/event-stream'. 具体操作可以看本仓库示例

chatgpt-sse-hide-example's People

Contributors

cgqaq avatar phodal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

heretic-g

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.