Exemplo n.º 1
0
func NewClient(url string) Client {
	return &client{
		httpClient:          cf_http.NewClient(),
		streamingHTTPClient: cf_http.NewStreamingClient(),

		reqGen: rata.NewRequestGenerator(url, Routes),
	}
}
func (cr *ClusterRunner) NewClient() *api.Client {
	client, err := api.NewClient(&api.Config{
		Address:    cr.Address(),
		Scheme:     cr.scheme,
		HttpClient: cf_http.NewStreamingClient(),
	})
	Expect(err).NotTo(HaveOccurred())
	return client
}
Exemplo n.º 3
0
func NewClient(urlString string) (*api.Client, error) {
	scheme, address, err := Parse(urlString)
	if err != nil {
		return nil, err
	}

	return api.NewClient(&api.Config{
		Address:    address,
		Scheme:     scheme,
		HttpClient: cf_http.NewStreamingClient(),
	})
}
Exemplo n.º 4
0
	Describe("NewClient", func() {
		It("returns an http client", func() {
			client := cf_http.NewClient()
			Expect(client.Timeout).To(Equal(timeout))
			transport := client.Transport.(*http.Transport)
			Expect(transport.Dial).NotTo(BeNil())
			Expect(transport.DisableKeepAlives).To(BeFalse())
		})
	})

	Describe("NewCustomTimeoutClient", func() {
		It("returns an http client with specified timeout", func() {
			client := cf_http.NewCustomTimeoutClient(5 * time.Second)
			Expect(client.Timeout).To(Equal(5 * time.Second))
			transport := client.Transport.(*http.Transport)
			Expect(transport.Dial).NotTo(BeNil())
			Expect(transport.DisableKeepAlives).To(BeFalse())
		})
	})

	Describe("NewStreamingClient", func() {
		It("returns an http client", func() {
			client := cf_http.NewStreamingClient()
			Expect(client.Timeout).To(BeZero())
			transport := client.Transport.(*http.Transport)
			Expect(transport.Dial).NotTo(BeNil())
			Expect(transport.DisableKeepAlives).To(BeFalse())
		})
	})
})