@@ -107,62 +107,6 @@ protected override TimeSpan TerminationTimeout
107107 get { return TimeSpan . FromMilliseconds ( 100 ) ; }
108108 }
109109
110- /// <summary>
111- /// Gets a value indicating whether the service is responding to HTTP requests.
112- /// </summary>
113- protected override bool IsInitialized
114- {
115- get
116- {
117- bool isInitialized = false ;
118- try
119- {
120- // Since Firefox driver won't implement the /session end point (because
121- // the W3C spec working group stupidly decided that it isn't necessary),
122- // we'll attempt to poll for a different URL which has no side effects.
123- // We've chosen to poll on the "quit" URL, passing in a nonexistent
124- // session id.
125- Uri serviceHealthUri = new Uri ( this . ServiceUrl , new Uri ( "/session/FakeSessionIdForPollingPurposes" , UriKind . Relative ) ) ;
126- HttpWebRequest request = HttpWebRequest . Create ( serviceHealthUri ) as HttpWebRequest ;
127- request . KeepAlive = false ;
128- request . Timeout = 5000 ;
129- request . Method = "DELETE" ;
130- HttpWebResponse response = request . GetResponse ( ) as HttpWebResponse ;
131-
132- // Checking the response from deleting a nonexistent session. Note that we are simply
133- // checking that the HTTP status returned is a 200 status, and that the resposne has
134- // the correct Content-Type header. A more sophisticated check would parse the JSON
135- // response and validate its values. At the moment we do not do this more sophisticated
136- // check.
137- isInitialized = response . StatusCode == HttpStatusCode . OK && response . ContentType . StartsWith ( "application/json" , StringComparison . OrdinalIgnoreCase ) ;
138- response . Close ( ) ;
139- }
140- catch ( WebException ex )
141- {
142- // Because the Firefox driver (incorrectly) does not allow quit on a
143- // nonexistent session to succeed, this will throw a WebException,
144- // which means we're reduced to using exception handling for flow control.
145- // This situation is highly undesirable, and in fact is a horrible code
146- // smell, but the implementation leaves us no choice. So we will check for
147- // the known response code and content type header, just like we would for
148- // the success case. Either way, a valid HTTP response instead of a socket
149- // error would tell us that the HTTP server is responding to requests, which
150- // is really what we want anyway.
151- HttpWebResponse errorResponse = ex . Response as HttpWebResponse ;
152- if ( errorResponse != null )
153- {
154- isInitialized = errorResponse . StatusCode == HttpStatusCode . InternalServerError && errorResponse . ContentType . StartsWith ( "application/json" , StringComparison . OrdinalIgnoreCase ) ;
155- }
156- else
157- {
158- Console . WriteLine ( ex . Message ) ;
159- }
160- }
161-
162- return isInitialized ;
163- }
164- }
165-
166110 /// <summary>
167111 /// Gets the command-line arguments for the driver service.
168112 /// </summary>
0 commit comments