Go Context原理及其典型适用场景Context原理及其适用场景 随手记 李帅(飞雪无情) n 常见并发模式 n Context实现原理 n TLS VS Context n 典型适用场景 大纲 Channel Fan-in func fanIn(sum1, sum2 <-chan int) <-chan int { sum := make(chan int) go func() { for {sum <- <-sum1} } } Context l 一个任务,需要多个goroutine完成 l 一个请求,会触发好多个goroutine做不同的事情 l 如果我们的任务终止了,请求取消了,这些正在运行 的goroutine怎么办? l 使用Context来简化这些操作 Context能做什么 u 手动、定时、超时发出取消信号 u 跨API传值 u 控制生成Context树结构(Context链) Context main() { rootCtx := context.Background() ctx, cancel := context.WithCancel(rootCtx) go watch(ctx) go watch(ctx) time.Sleep(1 * time.Second) cancel() } func watch(ctx context.Context) { for { select {0 码力 | 32 页 | 4.62 MB | 1 年前3
Java EE 企业应用系统开发 - HTTP 响应处理编程响应对象 响应对象功能和方法 HTTP 响应的内容 在 Web 服务器接收请求处理后,向客户端发送 HTTP 响应 (Response)。 O 响应的内容 ▶ 响应状态(Status Code) ▶ 响应头(Response Header) ▶ 响应体(Response Body) 大纲 HTTP 响应的内容 HTTP 响应对象 响应对象功能和方法 HTTP 响应状态行 表明响应的状态信息,如成功、失败、错误。 告知客户可以接收的字符集:Accept-Charset 3. 响应的字符编码集:Accept-Encoding 4. 响应体的 MIME 类型:Content-Type 5. 响应体的语言类型:Context-Language 6. 响应体的长度和字节数:Content-Length 7. 通知客户端到期时间:Expires 8. 缓存情况:Cache-Control 9. 重定向到另一个 URL 向客户端发送指定的错误信息码,可以是任意定义的整数。 1 response.setCharacterEncoding("GBK"); 2 response.sendError(580); O public void sendError(int sc, String msg) throws IOException 向客户端发送指定的错误信息码和自定义状态消息。 1 response.setCharacterEncoding("GBK");0 码力 | 26 页 | 575.28 KB | 1 年前3
httpd 2.4.25 中文文档for the proxy's clients. mod_sed An advanced replacement of mod_substitute, allows to edit the response body with the full power of sed. mod_auth_form Enables form-based authentication. mod_session processing. mod_buffer Provides for buffering the input and output filter stacks mod_data Convert response body into an RFC2397 data URL mod_ratelimit Provides Bandwidth Rate Limiting for Clients mod_request and make available HTTP request bodies mod_reflector Provides Reflection of a request body as a response via the output filter stack. mod_slotmem_shm Provides a Slot-based shared memory provider (ala0 码力 | 2573 页 | 2.12 MB | 1 年前3
httpd 2.4.23 中文文档for the proxy's clients. mod_sed An advanced replacement of mod_substitute, allows to edit the response body with the full power of sed. mod_auth_form Enables form-based authentication. mod_session processing. mod_buffer Provides for buffering the input and output filter stacks mod_data Convert response body into an RFC2397 data URL mod_ratelimit Provides Bandwidth Rate Limiting for Clients mod_request and make available HTTP request bodies mod_reflector Provides Reflection of a request body as a response via the output filter stack. mod_slotmem_shm Provides a Slot-based shared memory provider (ala0 码力 | 2559 页 | 2.11 MB | 1 年前3
httpd 2.4.20 中文文档for the proxy's clients. mod_sed An advanced replacement of mod_substitute, allows to edit the response body with the full power of sed. mod_auth_form Enables form-based authentication. mod_session processing. mod_buffer Provides for buffering the input and output filter stacks mod_data Convert response body into an RFC2397 data URL mod_ratelimit Provides Bandwidth Rate Limiting for Clients mod_request and make available HTTP request bodies mod_reflector Provides Reflection of a request body as a response via the output filter stack. mod_slotmem_shm Provides a Slot-based shared memory provider (ala0 码力 | 2533 页 | 2.09 MB | 1 年前3
httpd 2.4.33 中文文档for the proxy's clients. mod_sed An advanced replacement of mod_substitute, allows to edit the response body with the full power of sed. mod_auth_form Enables form-based authentication. mod_session processing. mod_buffer Provides for buffering the input and output filter stacks mod_data Convert response body into an RFC2397 data URL mod_ratelimit Provides Bandwidth Rate Limiting for Clients mod_request and make available HTTP request bodies mod_reflector Provides Reflection of a request body as a response via the output filter stack. mod_slotmem_shm Provides a Slot-based shared memory provider (ala0 码力 | 2692 页 | 3.12 MB | 1 年前3
httpd 2.4.28 中文文档for the proxy's clients. mod_sed An advanced replacement of mod_substitute, allows to edit the response body with the full power of sed. mod_auth_form Enables form-based authentication. mod_session processing. mod_buffer Provides for buffering the input and output filter stacks mod_data Convert response body into an RFC2397 data URL mod_ratelimit Provides Bandwidth Rate Limiting for Clients mod_request and make available HTTP request bodies mod_reflector Provides Reflection of a request body as a response via the output filter stack. mod_slotmem_shm Provides a Slot-based shared memory provider (ala0 码力 | 2659 页 | 3.10 MB | 1 年前3
httpd 2.4.18 中文文档for the proxy's clients. mod_sed An advanced replacement of mod_substitute, allows to edit the response body with the full power of sed. mod_auth_form Enables form-based authentication. mod_session processing. mod_buffer Provides for buffering the input and output filter stacks mod_data Convert response body into an RFC2397 data URL mod_ratelimit Provides Bandwidth Rate Limiting for Clients mod_request and make available HTTP request bodies mod_reflector Provides Reflection of a request body as a response via the output filter stack. mod_slotmem_shm Provides a Slot-based shared memory provider (ala0 码力 | 2467 页 | 1.89 MB | 1 年前3
httpd 2.4.17 中文文档for the proxy's clients. mod_sed An advanced replacement of mod_substitute, allows to edit the response body with the full power of sed. mod_auth_form Enables form-based authentication. mod_session processing. mod_buffer Provides for buffering the input and output filter stacks mod_data Convert response body into an RFC2397 data URL mod_ratelimit Provides Bandwidth Rate Limiting for Clients mod_request and make available HTTP request bodies mod_reflector Provides Reflection of a request body as a response via the output filter stack. mod_slotmem_shm Provides a Slot-based shared memory provider (ala0 码力 | 2455 页 | 1.88 MB | 1 年前3
httpd 2.4.16 中文文档for the proxy's clients. mod_sed An advanced replacement of mod_substitute, allows to edit the response body with the full power of sed. mod_auth_form Enables form-based authentication. mod_session processing. mod_buffer Provides for buffering the input and output filter stacks mod_data Convert response body into an RFC2397 data URL mod_ratelimit Provides Bandwidth Rate Limiting for Clients mod_request and make available HTTP request bodies mod_reflector Provides Reflection of a request body as a response via the output filter stack. mod_slotmem_shm Provides a Slot-based shared memory provider (ala0 码力 | 2438 页 | 1.87 MB | 1 年前3
共 501 条
- 1
- 2
- 3
- 4
- 5
- 6
- 51













