dongyihao9887 2016-07-06 07:43
浏览 487

如何通过Golang中的http连接访问net.conn?

My code looks like this at the moment:

package main

import (
   "io"
   "net/http"
   "fmt"
   "net"
)

const (
    PORT       = ":443"
    KEY   = "./localhost.key"
    CERT = "./localhost.crt"
)

func hello(w http.ResponseWriter, r *http.Request) {
    io.WriteString(w, "Hello world! :)")
}

func main() {
    http.HandleFunc("/", hello)
    http.ListenAndServeTLS(PORT, CERT, KEY, nil)
}

What I would like to be able to do is to use the net.Conn that is created when a client reaches my host. The reason behind this is to use golang.org/x/net/http2 in order to create custom frames and edit the transmission of data at a lower level. And for example http2.NewFramer requires a writer and a reader, which I guess would be the actual net.Conn in both cases.

I am pretty to new to Golang so any advice on how to improve myself is well welcomed. Thank you in advance everyone! :)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 关于#python#的问题:自动化测试