169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal// Copyright (c) 2012 The Chromium Authors. All rights reserved. 269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal// Use of this source code is governed by a BSD-style license that can be 369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal// found in the LICENSE file. 469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal#ifndef CHROME_TEST_CHROMEDRIVER_NET_NET_UTIL_H_ 669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal#define CHROME_TEST_CHROMEDRIVER_NET_NET_UTIL_H_ 769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal#include <string> 969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 1069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalclass URLRequestContextGetter; 1169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 1269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalclass NetAddress { 1369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal public: 1469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal NetAddress(); // Creates an invalid address. 1569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal explicit NetAddress(int port); // Host is set to 127.0.0.1. 1669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal NetAddress(const std::string& host, int port); 1769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal ~NetAddress(); 1869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 1969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal bool IsValid() const; 2069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 2169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal // Returns host:port. 2269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal std::string ToString() const; 2369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 2469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal const std::string& host() const; 2569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal int port() const; 2669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 2769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal private: 2869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal std::string host_; 2969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal int port_; 3069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal}; 3169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 3269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal// Synchronously fetches data from a GET HTTP request to the given URL. 3369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal// Returns true if response is 200 OK and sets response body to |response|. 3469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalbool FetchUrl(const std::string& url, 3569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal URLRequestContextGetter* getter, 3669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal std::string* response); 3769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 3869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal#endif // CHROME_TEST_CHROMEDRIVER_NET_NET_UTIL_H_ 3969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal