File tree Expand file tree Collapse file tree
base/src/main/java/com/tinyengine/it/mcp/tools Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -174,12 +174,16 @@ public static byte[] fetchBytes(String urlString) throws IOException {
174174 URL url = new URL (urlString );
175175 HttpURLConnection connection = (HttpURLConnection ) url .openConnection ();
176176 connection .setRequestMethod ("GET" );
177+ connection .setInstanceFollowRedirects (false );
177178 connection .setConnectTimeout (CONNECT_TIMEOUT );
178179 connection .setReadTimeout (READ_TIMEOUT );
179180 connection .setRequestProperty ("User-Agent" , "Java-URL-Client" );
180181
181182 try {
182183 int responseCode = connection .getResponseCode ();
184+ if (responseCode >= 300 && responseCode < 400 ) {
185+ throw new IOException ("Redirect responses are not allowed" );
186+ }
183187 if (responseCode != HttpURLConnection .HTTP_OK ) {
184188 throw new IOException ("HTTP response code: " + responseCode );
185189 }
You can’t perform that action at this time.
0 commit comments