• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /**
18  * A test EventHandler: Logs everything received
19  */
20 
21 package android.net.http;
22 
23 import android.net.http.Headers;
24 
25 /**
26  * {@hide}
27  */
28 public class LoggingEventHandler implements EventHandler {
29 
requestSent()30     public void requestSent() {
31         HttpLog.v("LoggingEventHandler:requestSent()");
32     }
33 
status(int major_version, int minor_version, int code, String reason_phrase)34     public void status(int major_version,
35                        int minor_version,
36                        int code, /* Status-Code value */
37                        String reason_phrase) {
38         if (HttpLog.LOGV) {
39             HttpLog.v("LoggingEventHandler:status() major: " + major_version +
40                   " minor: " + minor_version +
41                   " code: " + code +
42                   " reason: " + reason_phrase);
43         }
44     }
45 
headers(Headers headers)46     public void headers(Headers headers) {
47         if (HttpLog.LOGV) {
48             HttpLog.v("LoggingEventHandler:headers()");
49             HttpLog.v(headers.toString());
50         }
51     }
52 
locationChanged(String newLocation, boolean permanent)53     public void locationChanged(String newLocation, boolean permanent) {
54         if (HttpLog.LOGV) {
55             HttpLog.v("LoggingEventHandler: locationChanged() " + newLocation +
56                       " permanent " + permanent);
57         }
58     }
59 
data(byte[] data, int len)60     public void data(byte[] data, int len) {
61         if (HttpLog.LOGV) {
62             HttpLog.v("LoggingEventHandler: data() " + len + " bytes");
63         }
64         // HttpLog.v(new String(data, 0, len));
65     }
endData()66     public void endData() {
67         if (HttpLog.LOGV) {
68             HttpLog.v("LoggingEventHandler: endData() called");
69         }
70     }
71 
certificate(SslCertificate certificate)72     public void certificate(SslCertificate certificate) {
73          if (HttpLog.LOGV) {
74              HttpLog.v("LoggingEventHandler: certificate(): " + certificate);
75          }
76     }
77 
error(int id, String description)78     public void error(int id, String description) {
79         if (HttpLog.LOGV) {
80             HttpLog.v("LoggingEventHandler: error() called Id:" + id +
81                       " description " + description);
82         }
83     }
84 
handleSslErrorRequest(SslError error)85     public boolean handleSslErrorRequest(SslError error) {
86         if (HttpLog.LOGV) {
87             HttpLog.v("LoggingEventHandler: handleSslErrorRequest():" + error);
88         }
89         // return false so that the caller thread won't wait forever
90         return false;
91     }
92 }
93