proxy-wasm-go-sdk icon indicating copy to clipboard operation
proxy-wasm-go-sdk copied to clipboard

How to call a https request by use DispatchHttpCall ?

Open klausxie opened this issue 2 years ago • 2 comments

How to call a https request by use DispatchHttpCall

This is my code:

cluster := "outbound|443||httpbin.org"
headers := [][2]string{
    {":scheme", "https"},
    {":method", "GET"},
    {":path", "/get"},
    {":authority", "httpbin.org"},
    {"accept", "*/*"},
}
data, err := proxywasm.DispatchHttpCall(
    cluster,
    headers,
    nil,
    nil,
    1000,
    func(numHeaders, bodySize, numTrailers int) {
	    resp, _ := proxywasm.GetHttpCallResponseBody(0, 10000)
	    r := string(resp)
	    proxywasm.LogCriticalf("response: %v", r)
	    proxywasm.ResumeHttpRequest()
    })	

ServiceEntry.yaml

apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: external-svc-httpbin
spec:
  hosts:
    - httpbin.org
  location: MESH_EXTERNAL
  ports:
    - number: 443
      name: https
      protocol: TLS
  resolution: DNS

Response:

response: <html>
  <head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
  <body>
  <center><h1>400 Bad Request</h1></center>
  <center>The plain HTTP request was sent to HTTPS port</center>
  <hr><center>ALB</center>
  </body>
</html>

my question is how to call a HTTPS request

klausxie avatar Nov 23 '22 02:11 klausxie

I've encountered the same issue. @mathetake - do you know if it's even possible?

the-redshift avatar Mar 20 '23 14:03 the-redshift

Hi @mathetake could you please let me know if its possible?

harsha-konda avatar Dec 13 '23 18:12 harsha-konda

https://github.com/tetratelabs/proxy-wasm-go-sdk/pull/451

mathetake avatar Jul 27 '24 19:07 mathetake