@Override
	public <T extends OAuthResponse> T execute(Request request,
			Class<T> responseClass)
	{
		String responseBody = null;
		URLConnection c = null;
		int responseCode = 0;
		try
		{
			URL url = new URL(request.getLocationUri());

			c = url.openConnection();
			responseCode = -1;
			if (c instanceof HttpURLConnection)
			{
				HttpURLConnection httpURLConnection = (HttpURLConnection) c;

				if (request.getHeaders() != null)
				{
					for (Map.Entry<String, String> header : request
							.getHeaders().entrySet())
					{
						httpURLConnection.addRequestProperty(header.getKey(),
								header.getValue());
					}
				}

				String requestMethod = request.getRequestType();
				if (!OAuthKit.isEmpty(requestMethod))
				{
					httpURLConnection.setRequestMethod(requestMethod);
					if (requestMethod.equals(OAuth.HttpMethod.POST))
					{
						httpURLConnection.setDoOutput(true);
						OutputStream ost = httpURLConnection.getOutputStream();
						PrintWriter pw = new PrintWriter(ost);
						pw.print(OAuthKit.format(request.getBodyNameValuePair()
								.entrySet(), "UTF-8"));
						pw.flush();
						pw.close();
					}
				} else
				{
					httpURLConnection.setRequestMethod(OAuth.HttpMethod.GET);
				}

				httpURLConnection.connect();

				InputStream inputStream;
				responseCode = httpURLConnection.getResponseCode();
				if (responseCode == 400 || responseCode == 401)
				{
					inputStream = httpURLConnection.getErrorStream();
				} else
				{
					inputStream = httpURLConnection.getInputStream();
				}

				responseBody = OAuthKit.saveStreamAsString(inputStream);
			}
		} catch (IOException e)
		{
			throw new OAuthException(e);
		}

		return OAuthKit.createCustomResponse(responseBody, c.getContentType(),
				null, responseCode, responseClass);
	}