private void initConnection() {
		try {
			if (url.toURI().toString().contains("https")) {
				connection = (HttpsURLConnection) url.openConnection();
			} else {
				connection = (HttpURLConnection) url.openConnection();
			}

		} catch (IOException | URISyntaxException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

		if (type == RequestType.POST) {
			connection.setRequestProperty("Content-Length",
					String.valueOf(body.length()));
			connection.setRequestProperty("Content-Type",
					"application/x-www-form-urlencoded; charset=UTF-8");
		}
		if (!referer.equals("")) {
			connection.setRequestProperty("Referer", referer);
		}
		connection.setRequestProperty("Connection", "keep-alive");
		connection.setRequestProperty("DNT", "1");
		connection.setRequestProperty("Accept-Language",
				"de-de,de;q=0.8,en-us;q=0.5,en;q=0.3");
		connection
				.setRequestProperty("User-Agent",
						"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0");
		connection
				.setRequestProperty("Accept",
						"application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
		connection.setRequestProperty("Accept-Encoding", "gzip, deflate");

		 try {
		 setCookies();
		 } catch (IOException e) {
		 // TODO Auto-generated catch block
		 e.printStackTrace();
		 }
		if (type == RequestType.GET) {
			try {
				((HttpURLConnection) connection).setRequestMethod("GET");
				connection.setDoOutput(false);
			} catch (ProtocolException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} else {
			try {
				((HttpURLConnection) connection).setRequestMethod("POST");
				connection.setDoOutput(true);
			} catch (ProtocolException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		connection.setDoInput(true);

		connection.setUseCaches(true);
		connection.setRequestProperty("Host", url.getHost());
		if (ref) {
			connection.setDoInput(false);
		}
		// try {
		// connection.setRequestProperty("Cookie",
		// URLEncoder.encode(cookies, "UTF-8"));
		// } catch (UnsupportedEncodingException e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// }

	}