Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: src/org/adblockplus/brazil/BaseRequestHandler.java

Issue 5697499218051072: Usage of new API, cleanups (reduced) (Closed)
Left Patch Set: Created April 11, 2014, 1:31 p.m.
Right Patch Set: Even more review issues fixed. Created April 28, 2014, 10:18 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/org/adblockplus/android/updater/UpdaterService.java ('k') | src/org/adblockplus/brazil/RequestHandler.java » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 package org.adblockplus.brazil; 18 package org.adblockplus.brazil;
19 19
20 import java.util.Properties; 20 import java.util.Properties;
21 21
22 import sunlabs.brazil.server.Handler; 22 import sunlabs.brazil.server.Handler;
23 import sunlabs.brazil.server.Request; 23 import sunlabs.brazil.server.Request;
24 import sunlabs.brazil.server.Server; 24 import sunlabs.brazil.server.Server;
25 import sunlabs.brazil.util.http.MimeHeaders; 25 import sunlabs.brazil.util.http.MimeHeaders;
26 26
27 public abstract class BaseRequestHandler implements Handler 27 public abstract class BaseRequestHandler implements Handler
28 { 28 {
29 public final static String PROXY_HOST = "proxyHost";
30 public final static String PROXY_PORT = "proxyPort";
31 public final static String AUTH = "auth";
32 29
30 public static final String PROXY_HOST = "proxyHost";
31 public static final String PROXY_PORT = "proxyPort";
32 public static final String AUTH = "auth";
33 protected String proxyHost; 33 protected String proxyHost;
34 protected int proxyPort = 80; 34 protected int proxyPort = 80;
35 protected String auth; 35 protected String auth;
36 protected boolean shouldLogHeaders; 36 protected boolean shouldLogHeaders;
37
37 protected String prefix; 38 protected String prefix;
38 39
39 @Override 40 @Override
40 public boolean init(final Server server, final String prefix) 41 public boolean init(final Server server, final String prefix)
41 { 42 {
42 this.prefix = prefix; 43 this.prefix = prefix;
43 44
44 final Properties props = server.props; 45 final Properties props = server.props;
45 46
46 this.proxyHost = props.getProperty(prefix + PROXY_HOST); 47 proxyHost = props.getProperty(prefix + PROXY_HOST);
47 48
48 final String s = props.getProperty(prefix + PROXY_PORT); 49 final String s = props.getProperty(prefix + PROXY_PORT);
49
50 try 50 try
51 { 51 {
52 this.proxyPort = Integer.decode(s).intValue(); 52 proxyPort = Integer.decode(s).intValue();
53 } 53 }
54 catch (final Exception e) 54 catch (final Exception e)
55 { 55 {
56 } 56 }
57 57
58 this.auth = props.getProperty(prefix + AUTH); 58 auth = props.getProperty(prefix + AUTH);
59 59
60 this.shouldLogHeaders = (server.props.getProperty(prefix + "proxylog") != nu ll); 60 shouldLogHeaders = (server.props.getProperty(prefix + "proxylog") != null);
61 61
62 return true; 62 return true;
63 } 63 }
64 64
65 /** 65 /**
66 * Dump the headers on stderr 66 * Dump the headers on stderr
67 */ 67 */
68 public static String dumpHeaders(final int count, final Request request, final MimeHeaders headers, final boolean sent) 68 public static String dumpHeaders(final int count, final Request request, final MimeHeaders headers, final boolean sent)
69 { 69 {
70 String prompt; 70 String prompt;
(...skipping 11 matching lines...) Expand all
82 } 82 }
83 83
84 for (int i = 0; i < headers.size(); i++) 84 for (int i = 0; i < headers.size(); i++)
85 { 85 {
86 sb.append(prompt).append(headers.getKey(i)); 86 sb.append(prompt).append(headers.getKey(i));
87 sb.append(": ").append(headers.get(i)).append("\n"); 87 sb.append(": ").append(headers.get(i)).append("\n");
88 } 88 }
89 return (sb.toString()); 89 return (sb.toString());
90 } 90 }
91 } 91 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld