Mercurial Hosting > luan
comparison src/org/eclipse/jetty/util/resource/Resource.java @ 827:f89abbfb3a8f
remove Resource.getWeakETag()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 15 Sep 2016 16:21:56 -0600 |
parents | 7fb7c1915788 |
children | 7c737c376bc3 |
comparison
equal
deleted
inserted
replaced
826:6ebf86e4d2ca | 827:f89abbfb3a8f |
---|---|
29 import java.net.URLConnection; | 29 import java.net.URLConnection; |
30 import java.text.DateFormat; | 30 import java.text.DateFormat; |
31 import java.util.Arrays; | 31 import java.util.Arrays; |
32 import java.util.Date; | 32 import java.util.Date; |
33 | 33 |
34 import java.util.Base64; | |
35 import org.eclipse.jetty.util.IO; | 34 import org.eclipse.jetty.util.IO; |
36 import org.eclipse.jetty.util.Loader; | 35 import org.eclipse.jetty.util.Loader; |
37 import org.eclipse.jetty.util.StringUtil; | 36 import org.eclipse.jetty.util.StringUtil; |
38 import org.eclipse.jetty.util.URIUtil; | 37 import org.eclipse.jetty.util.URIUtil; |
39 import org.slf4j.Logger; | 38 import org.slf4j.Logger; |
639 throw new IllegalArgumentException(destination+" exists"); | 638 throw new IllegalArgumentException(destination+" exists"); |
640 writeTo(new FileOutputStream(destination),0,-1); | 639 writeTo(new FileOutputStream(destination),0,-1); |
641 } | 640 } |
642 | 641 |
643 /* ------------------------------------------------------------ */ | 642 /* ------------------------------------------------------------ */ |
644 public String getWeakETag() | |
645 { | |
646 StringBuilder b = new StringBuilder(32); | |
647 b.append("W/\""); | |
648 | |
649 long lhash = lastModified() ^ getName().hashCode() ^ length(); | |
650 byte[] a = new byte[Long.BYTES]; | |
651 for( int i=0; i<a.length; i++ ) { | |
652 a[i] = (byte)lhash; | |
653 lhash >>= 8; | |
654 } | |
655 b.append( Base64.getEncoder().encodeToString(a) ); | |
656 | |
657 b.append('"'); | |
658 return b.toString(); | |
659 } | |
660 | |
661 /* ------------------------------------------------------------ */ | |
662 /** Generate a properly encoded URL from a {@link File} instance. | 643 /** Generate a properly encoded URL from a {@link File} instance. |
663 * @param file Target file. | 644 * @param file Target file. |
664 * @return URL of the target file. | 645 * @return URL of the target file. |
665 * @throws MalformedURLException | 646 * @throws MalformedURLException |
666 */ | 647 */ |