Paket google.golang.org/appengine/urlfetch (v1.6.8)

Urlfetch paket menyediakan implementasi http.RoundTripper untuk mengambil URL melalui layanan urlfetch App Engine.

Variabel

ErrTruncatedBody

var ErrTruncatedBody = errors.New("urlfetch: truncated body")

ErrTruncatedBody adalah error yang ditampilkan setelah Read() akhir dari Isi respons jika isi tersebut telah terpotong oleh proxy App Engine.

Fungsi

func Client

func Client(ctx context.Context) *http.Client

Klien menampilkan *http.Client menggunakan Transport urlfetch default. Klien ini akan memeriksa validitas sertifikat SSL.

Batas waktu apa pun dari konteks yang diberikan akan digunakan untuk permintaan melalui klien ini. Jika klien tidak memiliki batas waktu, default App Engine 60 detik akan digunakan.

Transport

type Transport struct {
	Context context.Context

	// Controls whether the application checks the validity of SSL certificates
	// over HTTPS connections. A value of false (the default) instructs the
	// application to send a request to the server only if the certificate is
	// valid and signed by a trusted certificate authority (CA), and also
	// includes a hostname that matches the certificate. A value of true
	// instructs the application to perform no certificate validation.
	AllowInvalidServerCertificate bool
}

Transport adalah implementasi http.RoundTripper untuk App Engine. Pengguna umumnya harus membuat http.Client menggunakan transport ini dan menggunakan Klien, bukan menggunakan transport ini secara langsung.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (res *http.Response, err error)

RoundTrip mengeluarkan satu permintaan HTTP dan menampilkan responsnya. Sesuai dengan antarmuka http.RoundTripper, RoundTrip hanya menampilkan error jika ada permintaan yang tidak didukung atau proxy URL Fetch gagal. Perhatikan bahwa kode respons HTTP seperti 5xx, 403, 404, dll. bukanlah error selama transport terkait dan akan ditampilkan dengan err ditetapkan ke nil.