All Downloads are FREE. Search and download functionalities are using the official Maven repository.

le-annen.javaserver.0.1.source-code.ServerUtils Maven / Gradle / Ivy

Go to download

A minimal java http server which fulfills small portions of the http specifications. This is not a full fledged or secure server. It should only be used for learning purposes and contains no guarantees of any king.

The newest version!
import java.io.IOException;
import java.net.URLConnection;
import java.util.*;
import java.text.SimpleDateFormat;

class ServerUtils {
   String getHttpHeaderDate() {
    Calendar calendar = Calendar.getInstance();
    SimpleDateFormat dateFormat = new SimpleDateFormat(
            "EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
    dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
    return dateFormat.format(calendar.getTime());
  }

  String getHttpHeaderContentLength(String messageBody) {
     return Integer.toString(messageBody.getBytes().length);
  }

  String getFileMimeType(String _filePath) throws IOException {
     return URLConnection.guessContentTypeFromName(_filePath);
  }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy