<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ### 發起post請求 > fun NewRequest (methed, urlStr string, body io.Reader) (*Request error) > method,請求方法,如POST > urlStr,請求url > body,參數 ``` package main import ( "fmt" "io/ioutil" "net/http" "strings" ) func main() { // 客戶端對象 client := &http.Client{} // 請求體 body := ioutil.NopCloser(strings.NewReader("user=admin&pass=admin")) req, err := http.NewRequest("POST", "http://www.baidu.com", body) if err != nil { fmt.Println(err) } // 打印輸出body req_body, err := ioutil.ReadAll(req.Body) if err != nil { fmt.Println(err) } fmt.Println(string(req_body)) // post需要設置請求頭 req.Header.Set("Content-Type", "application/") // client.do方法后 會關閉 body resp, err := client.Do(req) if err != nil { fmt.Println(err) } fmt.Println(resp.Header["Content-Type"]) // 響應 Content-Type fmt.Println(resp.Request.Header["Content-Type"]) // 請求Content-Type } ``` ### 使用http包封裝的post方法 > func Post(url string, bodyType string, body io.Reader) (resp *Response, err error) > url string,請求的url > bodyType string,內容類型比如 application/x-www-form-urlencoded > body io.Reader,Post參數 ``` package main import ( "fmt" "io/ioutil" "net/http" "strings" ) func main() { // 使用http包的Post方法 response, err := http.Post("http://www.baidu.com", "application/x-www-form-urlencoded", strings.NewReader("user=admin&pass=admin")) if err != nil { fmt.Println(err) } // 結束關閉 body defer response.Body.Close() body, err := ioutil.ReadAll(response.Body) if err != nil { fmt.Println(err) } // 打印響應體 fmt.Println(string(body)) } ``` ### 使用http包的PostForm方法 > fun PostForm (url string, data url.Values) (resp *Response, err error) ``` package main import ( "fmt" "io/ioutil" "net/http" "net/url" ) func main() { // 使用PostForm發起請求 resp, err := http.PostForm("http://www.baidu.com", url.Values{"user": {"admin"}, "pass": {"admin"}}) if err != nil { fmt.Println(err) } // 結束關閉 defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err) } // 打印響應體 fmt.Println(string(body)) } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看