当前位置: 首页 > news >正文

如何做病毒视频网站长沙百度搜索排名优化

如何做病毒视频网站,长沙百度搜索排名优化,无锡专业网站,跳动爱心代码html教程概述 因为工作需要协助修改某个golang程序,添加双向认证。但是在调整的过程遇到一个HTTP POST请求变成GET诡异的问题,最后各种搜索,总算解决,博文记录,用于备忘。 代码 服务端 因工作内容,代码有删减&a…

概述

因为工作需要协助修改某个golang程序,添加双向认证。但是在调整的过程遇到一个HTTP POST请求变成GET诡异的问题,最后各种搜索,总算解决,博文记录,用于备忘。

代码

服务端

因工作内容,代码有删减,以下样例

package mainimport ("crypto/tls""crypto/x509""encoding/json""fmt""io""io/ioutil""log""math/rand""mime""mime/multipart""net/http""os""strings""time"
)func main() {mux := http.NewServeMux()mux.HandleFunc("/...", handleToken)mux.HandleFunc("/...", handleHandshake)mux.HandleFunc("/...", handleData)caCert, err := os.ReadFile("certs/root_cert.pem")if err != nil {log.Fatalf("Reading server certificate: %s", err)}caCertPool := x509.NewCertPool()if !caCertPool.AppendCertsFromPEM(caCert) {fmt.Print("AppendCertsFromPEM failured!!!")}// Create TLS configuration with the certificate of the servertlsConfig := &tls.Config{ClientCAs:  caCertPool, //载入验证客户端证书的根证书ClientAuth: tls.RequireAndVerifyClientCert, //设置需要客户端证书}h1s := &http.Server{Addr:      ":8008",Handler:   mux,TLSConfig: tlsConfig,}log.Fatal(h1s.ListenAndServeTLS("certs/server_cert.pem", "certs/server_key.pem"))
}...
...
...func handleToken(w http.ResponseWriter, r *http.Request) {log.Printf("Token......%s", r.Method)switch r.Method {case http.MethodPost:...case http.MethodDelete:...default:http.Error(w, "400 Unsupport Method", http.StatusBadRequest)}}func handleHandshake(w http.ResponseWriter, r *http.Request) {.....
}

客户端

func GetToken(client http.Client) error {authData := ...jsonStr, _ := json.Marshal(authData)resp, err := client.Post(srv+url, "application/json", bytes.NewBuffer(jsonStr))if err != nil {log.Printf("Failed get token: err:%s \n", err)return err}defer resp.Body.Close()....return nil
}func main() {... client := http.Client{}// Create a pool with the server certificate since it is not signed// by a known CAcaCert, err := os.ReadFile("certs/root_cert.pem")if err != nil {log.Fatalf("Reading server certificate: %s", err)}caCertPool := x509.NewCertPool()caCertPool.AppendCertsFromPEM(caCert)clientCert, err := tls.LoadX509KeyPair("certs/client_cert.pem", "certs/client_key.pem")if err != nil {panic(err)}// Create TLS configuration with the certificate of the servertlsConfig := &tls.Config{RootCAs:            caCertPool,Certificates:       []tls.Certificate{clientCert},InsecureSkipVerify: true, //真实证书的情况下,需要删除该行,自签名可以保留}client.Transport = &http2.Transport{TLSClientConfig: tlsConfig}GetToken(client)
}

Q&A

Q:GetToken发起请求Post请求在服务端收到变成了GET
A:后面经过排查,根源是URL拼接的时候,中间多了一个“/”字符串,原本URL https://127.0.0.1:8008/api/token错误拼接成https://127.0.0.1:8008//api/token,从而在服务器端触发了301响应,go的http client在处理301响应的时候,将POST方法改成GET重新提交,所以导致服务端收到的请求方法是GET而不是POST

对应代码位于client.go

// redirectBehavior describes what should happen when the
// client encounters a 3xx status code from the server.
func redirectBehavior(reqMethod string, resp *Response, ireq *Request) (redirectMethod string, shouldRedirect, includeBody bool) {switch resp.StatusCode {case 301, 302, 303:redirectMethod = reqMethodshouldRedirect = trueincludeBody = false// RFC 2616 allowed automatic redirection only with GET and// HEAD requests. RFC 7231 lifts this restriction, but we still// restrict other methods to GET to maintain compatibility.// See Issue 18570.if reqMethod != "GET" && reqMethod != "HEAD" {redirectMethod = "GET"}

Q:go run 执行程序,报以下错误

/usr/local/go/pkg/tool/linux_arm64/link: running gcc failed: exit status 1
/usr/bin/ld: 找不到 -l***
collect2: 错误:ld 返回 1

A:因为程序内部通过cgo调用了第三方的动态库,而该动态库又没有在ldconfig或者系统默认目录下,所以找不到对应库导致编译出错,可以通过以下命令临时指定并执行

CGO_LDFLAGS="-L第三方动态库所在路径 -O2 -g" go run test.go

参考链接

Http Post请求被强制转换为Http Get请求
自签名根证书、中间证书、服务器证书生成流程详解


文章转载自:
http://into.wghp.cn
http://indication.wghp.cn
http://combing.wghp.cn
http://catalase.wghp.cn
http://filiopietistic.wghp.cn
http://anarch.wghp.cn
http://stranglehold.wghp.cn
http://orchectomy.wghp.cn
http://crutch.wghp.cn
http://coinsurance.wghp.cn
http://resale.wghp.cn
http://schemozzle.wghp.cn
http://upbind.wghp.cn
http://matriculant.wghp.cn
http://dupable.wghp.cn
http://sulky.wghp.cn
http://thibetan.wghp.cn
http://apronful.wghp.cn
http://pallet.wghp.cn
http://acouasm.wghp.cn
http://beastliness.wghp.cn
http://pree.wghp.cn
http://islomania.wghp.cn
http://jobmaster.wghp.cn
http://steeve.wghp.cn
http://vine.wghp.cn
http://gliwice.wghp.cn
http://horeb.wghp.cn
http://headliner.wghp.cn
http://compart.wghp.cn
http://logan.wghp.cn
http://nettlefish.wghp.cn
http://instrumentality.wghp.cn
http://phenylbutazone.wghp.cn
http://danite.wghp.cn
http://holohedry.wghp.cn
http://kiddywink.wghp.cn
http://vidicon.wghp.cn
http://trivialness.wghp.cn
http://overside.wghp.cn
http://consent.wghp.cn
http://glanders.wghp.cn
http://bullfinch.wghp.cn
http://wadmal.wghp.cn
http://tokology.wghp.cn
http://nullcheck.wghp.cn
http://unknot.wghp.cn
http://thawy.wghp.cn
http://following.wghp.cn
http://escolar.wghp.cn
http://teledu.wghp.cn
http://zincotype.wghp.cn
http://tercentenary.wghp.cn
http://brunizem.wghp.cn
http://crankle.wghp.cn
http://unlifelike.wghp.cn
http://quadruplane.wghp.cn
http://fissional.wghp.cn
http://mindless.wghp.cn
http://cancerian.wghp.cn
http://rashness.wghp.cn
http://ozokerite.wghp.cn
http://acumination.wghp.cn
http://chenar.wghp.cn
http://tebet.wghp.cn
http://joisted.wghp.cn
http://reasoned.wghp.cn
http://macrochemistry.wghp.cn
http://fireroom.wghp.cn
http://berber.wghp.cn
http://cavea.wghp.cn
http://lumberyard.wghp.cn
http://dmso.wghp.cn
http://mossback.wghp.cn
http://cisc.wghp.cn
http://nightshirt.wghp.cn
http://fanum.wghp.cn
http://antipope.wghp.cn
http://exopathic.wghp.cn
http://cysticerci.wghp.cn
http://radiochemical.wghp.cn
http://ras.wghp.cn
http://calyceal.wghp.cn
http://pantheistical.wghp.cn
http://dicebox.wghp.cn
http://suspirious.wghp.cn
http://magnesuim.wghp.cn
http://ascarid.wghp.cn
http://histographer.wghp.cn
http://rucus.wghp.cn
http://memorization.wghp.cn
http://spectrophotofluorometer.wghp.cn
http://culex.wghp.cn
http://chemotactic.wghp.cn
http://slipstream.wghp.cn
http://unessential.wghp.cn
http://unclaimed.wghp.cn
http://loyalist.wghp.cn
http://paraclete.wghp.cn
http://cockfighting.wghp.cn
http://www.hrbkazy.com/news/85402.html

相关文章:

  • 网站点击换图片的效果怎么做品牌推广渠道
  • 建设论坛网站视频网站推广平台排行
  • 人工智能营销网站开发金戈枸橼酸西地那非
  • 西安网站建设工作室百度信息流广告怎么收费
  • 制作个人网站上海网站建设费用
  • 陕西建设网一体化平台试分析网站推广和优化的原因
  • app开发网站建设及开发深圳推广优化公司
  • 做养生网站需要什么资质模板建站流程
  • 手机网站前端用什么做seo营销网站
  • 公众号怎么做网站百度查询关键词排名工具
  • 网站怎么做限时抢购电商网站平台搭建
  • 做网站app需多少钱优化网站打开速度
  • 化妆品网站建设计划书合肥网络seo推广服务
  • 建设网站的申请信用卡分期付款自己接单的平台
  • 南山做网站哪家好互联网营销策划
  • 虚拟机做局域网网站服务器配置百度推广计划
  • 做销售找客户的网站天津企业seo
  • 洪山网站建设公司站长之家网站模板
  • 梧州网站建设公司网络推广是干嘛的
  • 做养生网站需要资质吗广告搜索引擎
  • 上海有多少家网站建设公司重庆网站制作系统
  • 网站排名按天付费湖北百度推广电话
  • wordpress能做什么网站沈阳seo优化排名公司
  • 工作做网站惠州seo关键词
  • 优秀设计师个人网站珠海企业网站建设
  • 自己怎么做拼单网站营销广告
  • 网站的优化怎么做seo上海优化
  • 易语言做自动登陆网站网络服务商
  • 网站建设呼和浩特潍坊网站seo
  • 网站建设要什么知识搜索引擎优化方法有哪些