remote_api/client.go
func NewClient(host string, client *http.Client) (*Client, error) {
	// Add an appcfg header to outgoing requests.
	wrapClient := new(http.Client)
	*wrapClient = *client
	t := client.Transport
	if t == nil {
		t = http.DefaultTransport
	}
	wrapClient.Transport = &headerAddingRoundTripper{t}

	url := url.URL{
		Scheme: "https",
		Host:   host,
		Path:   "/_ah/remote_api",
	}
	if host == "localhost" || strings.HasPrefix(host, "localhost:") {
		url.Scheme = "http"
	}
	u := url.String()
	appID, err := getAppID(wrapClient, u)
	if err != nil {
		return nil, fmt.Errorf("unable to contact server: %v", err)
	}
	return &Client{
		hc:    wrapClient,
		url:   u,
		appID: appID,
	}, nil
}
func NewClient(host string, client *http.Client) (*Client, error) {
	// Add an appcfg header to outgoing requests.
	wrapClient := new(http.Client)
	*wrapClient = *client
	t := client.Transport
	if t == nil {
		t = http.DefaultTransport
	}
	wrapClient.Transport = &headerAddingRoundTripper{t}

	url := url.URL{
		Scheme: "https",
		Host:   host,
		Path:   "/_ah/remote_api",
	}
	if host == "localhost" || strings.HasPrefix(host, "localhost:") {
		url.Scheme = "http"
	}
	u := url.String()
	appID, err := getAppID(wrapClient, u)
	if err != nil {
		return nil, fmt.Errorf("unable to contact server: %v", err)
	}
	return &Client{
		hc:    wrapClient,
		url:   u,
		appID: appID,
	}, nil
}
// NewClient returns a client for the given host. All communication will
// be performed over SSL unless the host is localhost.