Revision 6f03d6e1 trunk/Pithos.Network/RestClient.cs

b/trunk/Pithos.Network/RestClient.cs
157 157
            }
158 158
            catch (WebException exc)
159 159
            {
160
                Log.WarnFormat("[{0}] {1} {2}", request.Method, exc.Status, request.RequestUri);      
161
                if (!TryGetResponse(exc, out response))
160
                if (!TryGetResponse(exc, request,out response))
162 161
                    throw;
163 162
            }
164 163

  
......
181 180
            }
182 181
            catch (WebException exc)
183 182
            {
184
                Log.WarnFormat("[{0}] {1} {2}", request.Method, exc.Status,  request.RequestUri);     
185
                if (!TryGetResponse(exc, out response))
183
                if (!TryGetResponse(exc, request,out response))
186 184
                    throw;
187 185
            }
188 186

  
......
192 190
            return response;
193 191
        }
194 192

  
195
        private bool TryGetResponse(WebException exc, out HttpWebResponse response)
193
        private bool TryGetResponse(WebException exc, WebRequest request,out HttpWebResponse response)
196 194
        {
197 195
            response = null;
198 196
            //Fail on empty response
199 197
            if (exc.Response == null)
198
            {
199
                Log.WarnFormat("[{0}] {1} {2}", request.Method, exc.Status, request.RequestUri);     
200 200
                return false;
201
            }
201 202

  
202 203
            response = (exc.Response as HttpWebResponse);
204
            var statusCode = (int)response.StatusCode;
203 205
            //Succeed on allowed status codes
204 206
            if (AllowedStatusCodes.Contains(response.StatusCode))
207
            {
208
                if (Log.IsDebugEnabled)
209
                    Log.DebugFormat("[{0}] {1} {2}", request.Method, statusCode, request.RequestUri);     
205 210
                return true;
211
            }
212
            
213
            Log.WarnFormat("[{0}] {1} {2}", request.Method, statusCode, request.RequestUri);
206 214

  
207 215
            //Does the response have any content to log?
208 216
            if (exc.Response.ContentLength > 0)

Also available in: Unified diff