Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

How to call a https request by use DispatchHttpCall ? #346

@klausxie

Description

@klausxie

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions