public Response handle(Request req) {
		try {
			Matcher m = textureUrl.matcher(req.getPath());
			m.matches();
			String hash = m.group(1);
			String id = hash.substring(0, 32);
			char type = hash.charAt(60);

			URL skinUrl = null;
			if (type == '0') { // Skin
				skinUrl = skinLookup.get(id);
			} else if (type == '1') { // Cape
				skinUrl = capeLookup.get(id);
			}

			//System.out.println("TextureHandler.handle type: " + type);
                        byte[] data = new byte[0];
                        int responseCode = 404;
                        if (skinUrl != null){
                            String protocol = skinUrl.getProtocol();
                            if (protocol.equalsIgnoreCase("https")){
                                HttpsURLConnection conn = (HttpsURLConnection) skinUrl.openConnection();
                                conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393");
                                conn.setInstanceFollowRedirects(true);
                                responseCode = conn.getResponseCode();
                                data = Streams.toByteArray(conn.getInputStream());
                                
                            } else if (protocol.equalsIgnoreCase("http")){
                                HttpURLConnection conn = (HttpURLConnection) skinUrl.openConnection();
                                conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393");
                                conn.setInstanceFollowRedirects(true);
                                responseCode = conn.getResponseCode();
                                data = Streams.toByteArray(conn.getInputStream());
                                if (data.length == 0){
                                    return new Response(responseCode, data);
                                }
                            }
                        } else {
                            return new Response(404, data);
                        }
                        System.out.println("Texture response code: " + responseCode);
                        if (data.length == 0){
                            return new Response(responseCode, data);
                        }
			return new Response(data);
		} catch (IOException e) {
			e.printStackTrace();

			return null;
		}
	}