MCPcopy Index your code
hub / github.com/BombusMod/BombusMod / open

Method open

src/main/java/io/HttpProxyConnection.java:35–62  ·  view source on GitHub ↗
(String hostAddr, int port, String proxyAddr, int proxyPort, String userName, String userPass)

Source from the content-addressed store, hash-verified

33 private HttpProxyConnection() {}
34
35 public static HttpProxyConnection open(String hostAddr, int port, String proxyAddr, int proxyPort, String userName, String userPass) throws IOException{
36 HttpProxyConnection pconn=new HttpProxyConnection();
37
38 pconn.conn = new Socket(proxyAddr, proxyPort);
39 pconn.is=pconn.conn.getInputStream();
40 pconn.os=pconn.conn.getOutputStream();
41 String auth = "Proxy-Authorization: Basic ";
42 String req = "";
43 if (userName.length()>0 && userPass.length()>0) {
44 auth += Strconv.toBase64(userName + ":" + userPass);
45 req = "CONNECT " + hostAddr + ":" + port + " HTTP/1.0\r\nHost: " + hostAddr
46 + "\r\n" + auth + "\r\nPragma: no-cache\r\n\r\n";
47 } else {
48
49 req= "CONNECT " + hostAddr + ":" + port + " HTTP/1.0\r\nHost: " + hostAddr
50 + "\r\nPragma: no-cache\r\n\r\n";
51 }
52
53 pconn.os.write(req.getBytes());
54
55 String inpLine=pconn.readLine();
56 if (inpLine.indexOf("200",0)<=0) throw new IOException(inpLine);
57 while (inpLine.length()>0) {
58 inpLine=pconn.readLine();
59 }
60
61 return pconn;
62 }
63
64 public String readLine() throws IOException {
65 StringBuffer buf=new StringBuffer();

Callers 3

getResourceAsStreamMethod · 0.80
getResourceAsStreamMethod · 0.80
JabberStreamMethod · 0.80

Calls 4

toBase64Method · 0.95
readLineMethod · 0.95
writeMethod · 0.80
getBytesMethod · 0.45

Tested by

no test coverage detected