Changeset 14627
- Timestamp:
- 02/16/14 21:25:20 (10 years ago)
- Location:
- trunk/abcl
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/Debug.java
r13700 r14627 87 87 } 88 88 89 @SuppressWarnings("CallToThreadDumpStack") 89 90 public static final void trace(Throwable t) 90 91 { … … 92 93 } 93 94 95 public static final void trace(String message, Throwable t) 96 { 97 trace(message); 98 trace(t); 99 } 94 100 public static final Symbol _DEBUG_WARN_ 95 101 = exportSpecial("*DEBUG-WARN*", PACKAGE_SYS, NIL); -
trunk/abcl/src/org/armedbear/lisp/ZipCache.java
r14598 r14627 165 165 // headers, which if we don't find, we give up and 166 166 // refetch the resource. 167 String dateString = HttpHead.get(url, "Last-Modified"); 167 String dateString = null; 168 try { 169 dateString = HttpHead.get(url, "Last-Modified"); 170 } catch (IOException ex) { 171 Debug.trace(ex); 172 } 168 173 Date date = null; 169 174 ParsePosition pos = new ParsePosition(0); -
trunk/abcl/src/org/armedbear/lisp/util/HttpHead.java
r14612 r14627 38 38 import java.io.IOException; 39 39 import java.io.InputStreamReader; 40 import java.io.OutputStreamWriter; 40 41 import java.io.PrintWriter; 41 42 import java.net.InetSocketAddress; … … 49 50 */ 50 51 public class HttpHead { 51 static private String get(String urlString, String key) {52 static private String get(String urlString, String key) throws IOException { 52 53 URL url = null; 53 54 try { … … 59 60 } 60 61 61 static public String get(URL url, String key) {62 static public String get(URL url, String key) throws IOException { 62 63 Socket socket = null; 63 64 String result = null; … … 68 69 return result; 69 70 } 70 71 socket = new Socket(Proxy.NO_PROXY); // XXX add Proxy 72 71 String host = url.getHost(); 73 72 int port = url.getPort(); 74 73 if (port == -1) { 75 74 port = 80; 76 75 } 77 InetSocketAddress address = new InetSocketAddress(url.getHost(), port); 78 try { 79 socket.connect(address, 5000); // ??? too long? too short? 80 } catch (IOException ex) { 81 log("Connection failed: " + ex); 82 return result; 83 } 84 76 socket = new Socket(host, port); 77 85 78 PrintWriter out = null; 86 79 BufferedReader in = null; 87 80 try { 88 81 socket.setSoTimeout(5000); // ms 89 out = new PrintWriter( socket.getOutputStream());82 out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()), true); 90 83 in = new BufferedReader(new InputStreamReader(socket.getInputStream())); 91 84 } catch (IOException e) { … … 94 87 } 95 88 89 String CRLF = "\r\n"; 96 90 String head = "HEAD " + url.getPath() + " HTTP/1.1"; 97 out.print ln(head);98 out.print ln("Host: " + url.getAuthority());99 out.print ln("Connection: close");100 out.print ln("");91 out.print(head + CRLF); 92 out.print("Host: " + url.getAuthority() + CRLF); 93 out.print("Connection: close" + CRLF); 94 out.print(CRLF); 101 95 out.flush(); 102 96 … … 106 100 } catch (IOException e) { 107 101 log("Failed to read HTTP response: " + e); 102 } 103 if (line == null) { 104 throw new IOException("Could not access URL to parse headers."); 108 105 } 109 106 String status[] = line.split("\\s"); … … 155 152 156 153 public static void main(String argv[]) { 157 if (argv.length != 1) { 158 System.out.println("Usage: <cmd> URL"); 159 return; 160 } 161 String modified = get(argv[0], "Last-Modified"); 162 if (modified != null) { 163 System.out.println("Last-Modified: " + modified); 164 } else { 165 System.out.println("No result returned."); 166 } 154 if (argv.length != 1) { 155 System.out.println("Usage: <cmd> URL"); 156 return; 157 } 158 String modified = null; 159 try { 160 modified = get(argv[0], "Last-Modified"); 161 } catch (IOException ex) { 162 System.err.println("Unable to get Last-Modified header: "); 163 ex.printStackTrace(System.err); 164 } 165 if (modified != null) { 166 System.out.println("Last-Modified: " + modified); 167 } else { 168 System.out.println("No result returned."); 169 } 167 170 } 168 171 } -
trunk/abcl/test/lisp/abcl/jar-pathname.lisp
r14613 r14627 150 150 t) 151 151 152 çu(deftest jar-pathname.load.5152 (deftest jar-pathname.load.5 153 153 (load-from-jar *tmp-jar-path* "eek.lisp") 154 154 t) … … 210 210 211 211 ;;; wrapped in PROGN for easy disabling without a network connection 212 ;;; XXX come up with a better abstraction213 214 ;; disable until fix loading fasls via HTTP215 #+nil Bombs JVM! --ME 20140126216 212 (progn 217 213 (deftest jar-pathname.load.http.1 -
trunk/abcl/test/src/org/armedbear/lisp/util/HttpHeadTest.java
r14611 r14627 1 /*2 * To change this license header, choose License Headers in Project Properties.3 * To change this template file, choose Tools | Templates4 * and open the template in the editor.5 */6 7 1 package org.armedbear.lisp.util; 8 2 3 import java.io.IOException; 9 4 import java.net.MalformedURLException; 10 5 import java.net.URL; … … 18 13 import static org.junit.Assert.*; 19 14 20 /**21 *22 * @author evenson23 */24 15 public class HttpHeadTest { 25 16 … … 43 34 } 44 35 45 /**46 * Test of get method, of class HttpHead.47 */48 36 @Test 49 37 public void testGet() { 50 System.out.println("get");51 38 URL url = null; 52 39 try { 53 url = new URL("http://abcl -dynamic-install.googlecode.com/files/baz-20130403a.jar");40 url = new URL("http://abcl.org/fasl/42/baz-20140105a-fasl-42.jar"); 54 41 } catch (MalformedURLException ex) { 55 42 Logger.getLogger(HttpHeadTest.class.getName()).log(Level.SEVERE, null, ex); 56 43 } 57 44 String key = "Last-Modified"; 58 String expResult = ""; 59 String result = HttpHead.get(url, key); 60 assertEquals(expResult, result); 61 System.out.println("Last-Modifed result was "+ result); 62 fail("The test case is a prototype."); 45 String result = null; 46 try { 47 result = HttpHead.get(url, key); 48 } catch (IOException ex) { 49 Logger.getLogger(HttpHeadTest.class.getName()).log(Level.SEVERE, null, ex); 50 } 51 assertNotNull(result); 52 System.out.println("Last-Modified result was "+ result); 63 53 } 64 54 65 /**66 * Test of main method, of class HttpHead.67 */68 55 @Test 69 56 public void testMain() { 70 57 System.out.println("main"); 71 String[] argv = null;58 String[] argv = {"http://google.com/"}; 72 59 HttpHead.main(argv); 73 // TODO review the generated test code and remove the default call to fail.74 fail("The test case is a prototype.");75 60 } 76 61
Note: See TracChangeset
for help on using the changeset viewer.