summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2004-02-25 12:05:37 +0000
committermichelou <michelou@epfl.ch>2004-02-25 12:05:37 +0000
commit7b9dbbfaf514656d9313f2361871d1ee1d5ac78f (patch)
tree77f1c41ae2ca97d994629e65fc4a9f283d427eb6 /sources
parent333d2fd8ba2ce9b9e21a0fd41baab6beb443c5f3 (diff)
downloadscala-7b9dbbfaf514656d9313f2361871d1ee1d5ac78f.tar.gz
scala-7b9dbbfaf514656d9313f2361871d1ee1d5ac78f.tar.bz2
scala-7b9dbbfaf514656d9313f2361871d1ee1d5ac78f.zip
- added encoding scheme to 'URLDecoder.decode'.
- added '.png' and '.scala' extension in 'guessContentTypeFromName'.
Diffstat (limited to 'sources')
-rwxr-xr-xsources/scala/tools/scaladoc/HTTPServer.java32
1 files changed, 22 insertions, 10 deletions
diff --git a/sources/scala/tools/scaladoc/HTTPServer.java b/sources/scala/tools/scaladoc/HTTPServer.java
index f466696064..c87b2a119d 100755
--- a/sources/scala/tools/scaladoc/HTTPServer.java
+++ b/sources/scala/tools/scaladoc/HTTPServer.java
@@ -155,6 +155,8 @@ public class HTTPServer extends Thread {
class RequestProcessor implements Runnable {
+ private final static String ENCODING_SCHEME = "UTF-8";
+
private static List pool = new LinkedList();
private File documentRootDirectory;
private String indexFileName = "index.html";
@@ -192,17 +194,22 @@ class RequestProcessor implements Runnable {
*/
public static Map parseQuery(String query) {
Map map = new HashMap();
- String[] bindings = query.split("\\&");
- String regexp = "([^=]*)=([^=]*)";
- Pattern p = Pattern.compile(regexp);
- for(int i = 0; i < bindings.length; i++) {
- Matcher m = p.matcher(bindings[i]);
- if (m.find()) {
- String key = URLDecoder.decode(m.group(1));
- String value = URLDecoder.decode(m.group(2));
- map.put(key, value);
+ try {
+ String[] bindings = query.split("\\&");
+ String regexp = "([^=]*)=([^=]*)";
+ Pattern p = Pattern.compile(regexp);
+ for (int i = 0; i < bindings.length; i++) {
+ Matcher m = p.matcher(bindings[i]);
+ if (m.find()) {
+ String key = URLDecoder.decode(m.group(1), ENCODING_SCHEME);
+ String value = URLDecoder.decode(m.group(2), ENCODING_SCHEME);
+ map.put(key, value);
+ }
}
}
+ catch (UnsupportedEncodingException e) {
+ System.out.println("Une exception: " + e);
+ }
return map;
}
@@ -367,7 +374,9 @@ class RequestProcessor implements Runnable {
if (name.endsWith(".html") || name.endsWith(".htm")) {
return "text/html";
}
- else if (name.endsWith(".txt") || name.endsWith(".java")) {
+ else if (name.endsWith(".txt") ||
+ name.endsWith(".java") ||
+ name.endsWith(".scala")) {
return "text/plain";
}
else if (name.endsWith(".gif")) {
@@ -379,6 +388,9 @@ class RequestProcessor implements Runnable {
else if (name.endsWith(".jpg") || name.endsWith(".jpeg")) {
return "image/jpeg";
}
+ else if (name.endsWith(".png")) {
+ return "image/png";
+ }
else return "text/plain";
}