1c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath/* 22231db3e6bb54447a9b14cf004a6cb03c373651cjwilson * Copyright (C) 2012 Square, Inc. 3c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath * 4c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath * Licensed under the Apache License, Version 2.0 (the "License"); 5c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath * you may not use this file except in compliance with the License. 6c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath * You may obtain a copy of the License at 7c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath * 8c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath * http://www.apache.org/licenses/LICENSE-2.0 9c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath * 10c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath * Unless required by applicable law or agreed to in writing, software 11c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath * distributed under the License is distributed on an "AS IS" BASIS, 12c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath * See the License for the specific language governing permissions and 14c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath * limitations under the License. 15c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath */ 167c7f22d80748dc444d5da3c5be11d7d81ef14a2bLorenzo Colittipackage com.squareup.okhttp; 17c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath 182231db3e6bb54447a9b14cf004a6cb03c373651cjwilsonimport java.net.InetAddress; 192231db3e6bb54447a9b14cf004a6cb03c373651cjwilsonimport java.net.UnknownHostException; 20c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath 212231db3e6bb54447a9b14cf004a6cb03c373651cjwilson/** 222231db3e6bb54447a9b14cf004a6cb03c373651cjwilson * Domain name service. Prefer this over {@link InetAddress#getAllByName} to 232231db3e6bb54447a9b14cf004a6cb03c373651cjwilson * make code more testable. 242231db3e6bb54447a9b14cf004a6cb03c373651cjwilson */ 257c7f22d80748dc444d5da3c5be11d7d81ef14a2bLorenzo Colittipublic interface HostResolver { 267c7f22d80748dc444d5da3c5be11d7d81ef14a2bLorenzo Colitti HostResolver DEFAULT = new HostResolver() { 2754cf3446000fdcf88a9e62724f7deb0282e98da1jwilson @Override public InetAddress[] getAllByName(String host) throws UnknownHostException { 283c938a3f6b61ce5e2dba0d039b03fe73b89fd26cNeil Fuller if (host == null) throw new UnknownHostException("host == null"); 2954cf3446000fdcf88a9e62724f7deb0282e98da1jwilson return InetAddress.getAllByName(host); 3054cf3446000fdcf88a9e62724f7deb0282e98da1jwilson } 3154cf3446000fdcf88a9e62724f7deb0282e98da1jwilson }; 32c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath 3354cf3446000fdcf88a9e62724f7deb0282e98da1jwilson InetAddress[] getAllByName(String host) throws UnknownHostException; 34c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath} 35