You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Thorsten Heit <he...@icloud.com.INVALID> on 2025/04/16 18:35:29 UTC
Content type unknown after upgrading Tomcat 10.1.39 => 10.1.40
Hi all,
long time Tomcat user, but first time I'm posting, so hi to you all :-)
I'm suffering a strange phenomenon after I upgraded Tomcat on one of our
virtual machines from 10.1.39 to 10.1.40:
When I open the link to an application being served by Tomcat my browser
(Firefox) now downloads a file instead of displaying the (generated)
HTML page. With the network inspector I discovered that the content-type
in the response is set to "content/unknown;charset=UTF-8". When
reverting back to 10.1.39 everything works; the content-type in the
response is (as expected) "text/html;charset=UTF-8".
In the changelog I haven't seen anything regarding this.
The configuration files used to start Tomcat are exactly the same in
both scenarios, and the application isn't changed.
Can anyone explain what's happening?
Tomcat: 10.1.39 / 40
Java: openjdk-21.0.6
OS: Ubuntu 24.04.2 LTS
Best regards
Thorsten
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Content type unknown after upgrading Tomcat 10.1.39 => 10.1.40
Posted by Thorsten Heit <he...@icloud.com.INVALID>.
Hi Mark,
> That looks like the result of fixing this bug:
> https://bz.apache.org/bugzilla/show_bug.cgi?id=69623
>
> A little more digging suggests that MIME type is only set for a resource
> when it is served via the default servlet. I suspect that lookup needs
> to be moved so MIME type is also available when the default servlet is
> not used.
>
> I should be able to put together a test case for what I think the
> problem is but I'd like to be sure it is fixing the problem you are
> seeing. There are a couple of options:
>
> 1. You test a SNAPSHOT build of Tomcat 10.1.x from the CI system that
> contains the fix once I have implemented what I think is the fix.
>
> 2. You provide the simplest possible web application that reproduces the
> issue and I use that to test.
Thanks for your answer. I see whether I can create a minimal reproducer.
Regards
Thorsten
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Content type unknown after upgrading Tomcat 10.1.39 => 10.1.40
Posted by Mark Thomas <ma...@apache.org>.
On 16/04/2025 19:35, Thorsten Heit wrote:
> Hi all,
>
> long time Tomcat user, but first time I'm posting, so hi to you all :-)
>
> I'm suffering a strange phenomenon after I upgraded Tomcat on one of our
> virtual machines from 10.1.39 to 10.1.40:
>
> When I open the link to an application being served by Tomcat my browser
> (Firefox) now downloads a file instead of displaying the (generated)
> HTML page. With the network inspector I discovered that the content-type
> in the response is set to "content/unknown;charset=UTF-8". When
> reverting back to 10.1.39 everything works; the content-type in the
> response is (as expected) "text/html;charset=UTF-8".
>
> In the changelog I haven't seen anything regarding this.
>
> The configuration files used to start Tomcat are exactly the same in
> both scenarios, and the application isn't changed.
>
> Can anyone explain what's happening?
That looks like the result of fixing this bug:
https://bz.apache.org/bugzilla/show_bug.cgi?id=69623
A little more digging suggests that MIME type is only set for a resource
when it is served via the default servlet. I suspect that lookup needs
to be moved so MIME type is also available when the default servlet is
not used.
I should be able to put together a test case for what I think the
problem is but I'd like to be sure it is fixing the problem you are
seeing. There are a couple of options:
1. You test a SNAPSHOT build of Tomcat 10.1.x from the CI system that
contains the fix once I have implemented what I think is the fix.
2. You provide the simplest possible web application that reproduces the
issue and I use that to test.
Which approach works best for you?
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Content type unknown after upgrading Tomcat 10.1.39 => 10.1.40
Posted by Christopher Schultz <ch...@christopherschultz.net>.
Thorsten,
On 5/2/25 2:49 PM, Thorsten Heit wrote:
> please excuse the long delay in answering (unplanned holidays...)
>
>> Tomcat is never going to figure out what MIME type should be used for
>> a request like "/my/servlet/app?version=!!1.22.32-4-g8a3c060!!"
>>
>> So I think Mark is probably right (well, he's right like 99.999% of
>> the time, so...) about this being related to https://bz.apache.org/
>> bugzilla/ show_bug.cgi?id=69623 but I suspect your servlet is not
>> explicitly setting a content-type.
>
> It took quite some time debugging into our application to find out the
> place where the output difference happens between Tomcat 10.1.39 and
> 10.1.40:
>
> We're using our own template engine that renders the HTML output,
> depending on the actual state of the application for the (logged-in)
> user. Basically the code is working the same way as this minimal
> reproducer:
Thanks for the reproducer. I can confirm that on my Tomcat/10.1.41-dev
environment I am receiving this response:
$ curl -v http://localhost:8080/test/hello
* Host localhost:8080 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
* Trying [::1]:8080...
* Connected to localhost (::1) port 8080
> GET /test/hello HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/8.7.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 200
< Content-Type: content/unknown;charset=UTF-8
< Content-Length: 226
< Date: Mon, 05 May 2025 15:48:59 GMT
<
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
<title>Hello World!</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>
* Connection #0 to host localhost left intact
Note that your call to getResource("HelloWorld.html") is technically
illegal as your string must begin with a / but it worked once I got
HelloWorld.html into the right place :)
If I make the following change, I get the expected text/html
content-type coming back:
var output = baos.toByteArray();
response.setContentLength(length);
- response.setContentType(contentType);
+ //response.setContentType(contentType);
try (var os = response.getOutputStream()) {
os.write(output, 0, output.length);
That is, if you don't try to change the content-type a second time.
So it seems that URLConnection.getContentType is returning an unexpected
content type.
ServletContext.getResource().openConnection() is returning an instance
of
org.apache.catalina.webresources.CachedResource$CachedResourceURLConnection
The code for CachedResourceURLConnection.getContentType is:
@Override
public String getContentType() {
// "content/unknown" is the value used by
sun.net.www.URLConnection. It is used here for consistency.
return
Objects.requireNonNullElse(getResource().getMimeType(), "content/unknown");
}
So I think this is "expected behavior", though it may not be expected by
you.
My assertion that returning text/unknown was a Tomcat bug was based upon
the idea that Tomcat was either providing the wrong default (as per HTTP
spec) MIME type for an HTTP response, or that Tomcat was somehow
ignoring the content type you explicitly requested, but neither are the
case.
The cached resource is not providing the correct MIME type, but that
content type is being used without re-checking it in any way.
Instead of using the content type coming from the URLConnection, perhaps
you want to use name-based MIME type detection?
contentType =
request.getServletContext().getMimeType("HelloWorld.html");
But the change that did it was 84608e11906b4d56e74a3ea2f5a4df0b9e8ee09a:
+
+ @Override
+ public String getContentType() {
+ // "content/unknown" is the value used by
sun.net.www.URLConnection. It is used here for consistency.
+ return
Objects.requireNonNullElse(getResource().getMimeType(), "content/unknown");
+ }
This was added to fix this bug:
https://bz.apache.org/bugzilla/show_bug.cgi?id=69623
It seems that returning a null MIME type here causes problems
downstream. I might change your code to this:
- if (null == contentType) {
+ if (null == contentType || contentType.equals("content/unknown")) {
contentType = "text/html";
}
This will make the code compatible with Sun's URLConnection class when
it can't determine the content-type of a resource.
I think an argument might be made for attempting to use Tomcat's
existing filename-based MIME registry from within this class, though.
-chris
> package com.example;
>
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
>
> import jakarta.servlet.ServletException;
> import jakarta.servlet.annotation.WebServlet;
> import jakarta.servlet.http.HttpServlet;
> import jakarta.servlet.http.HttpServletRequest;
> import jakarta.servlet.http.HttpServletResponse;
>
> @WebServlet("/HelloWorld")
> public class HelloWorld extends HttpServlet {
> @Override
> protected void doGet(HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException {
> response.setContentType("text/html; charset=UTF-8");
> var resource =
> request.getServletContext().getResource("HelloWorld.html");
> var connection = resource.openConnection();
>
> String contentType = connection.getContentType();
> if (null == contentType) {
> contentType = "text/html";
> }
> var length = connection.getContentLength();
> var baos = new ByteArrayOutputStream();
> try (var is = connection.getInputStream()) {
> is.transferTo(baos);
> }
> var output = baos.toByteArray();
>
> response.setContentLength(length);
> response.setContentType(contentType);
> try (var os = response.getOutputStream()) {
> os.write(output, 0, output.length);
> }
> }
> }
>
>
> web.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
> http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
> version="3.1" metadata-complete="true">
> <display-name>Hello World Web Application</display-name>
> <servlet>
> <servlet-name>HelloWorld</servlet-name>
> <servlet-class>com.example.HelloWorld</servlet-class>
> </servlet>
> <servlet-mapping>
> <servlet-name>HelloWorld</servlet-name>
> <url-pattern>/*</url-pattern>
> </servlet-mapping>
> </web-app>
>
>
> HelloWorld.html:
>
> <!DOCTYPE html>
> <html>
> <head>
> <meta charset="UTF-8">
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
> <title>Hello World!</title>
> </head>
> <body>
> <p>Hello World!</p>
> </body>
> </html>
>
>
>
> With Tomcat 10.1.39 I'm getting the following result with curl:
>
> %> curl -v http://localhost:8080/hello
>
> (...)
> * Request completely sent off
> < HTTP/1.1 200
> < Content-Type: text/html;charset=UTF-8
> < Content-Length: 212
> (...)
>
>
> With Tomcat 10.1.40:
>
> (...)
> * Request completely sent off
> < HTTP/1.1 200
> < Content-Type: content/unknown;charset=UTF-8
> < Content-Length: 212
> (...)
>
>
> The reason is exactly what you assumed and the change that Mark mentioned:
> Since 10.1.40 the class CachedResource$CachedResourceURLConnection now
> has a new method "public String getContentType()" that is causing this
> difference...
>
>
> Ok, we could change our code so that in case the content type is set to
> "content/unknown" we're replacing that by "text/html". OTOH with respect
> to our customers this isn't really a good solution: On the one hand they
> partly have older releases that would have to be patched. On the other
> hand we normally don't have control about their environment; we could
> only give advises, especially in this case don't upgrade to Tomcat
> 10.1.40...
>
>
> WDYT?
>
> Thorsten
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Content type unknown after upgrading Tomcat 10.1.39 => 10.1.40
Posted by Thorsten Heit <he...@icloud.com.INVALID>.
Hi Chris,
please excuse the long delay in answering (unplanned holidays...)
> Tomcat is never going to figure out what MIME type should be used for a
> request like "/my/servlet/app?version=!!1.22.32-4-g8a3c060!!"
>
> So I think Mark is probably right (well, he's right like 99.999% of the
> time, so...) about this being related to https://bz.apache.org/bugzilla/
> show_bug.cgi?id=69623 but I suspect your servlet is not explicitly
> setting a content-type.
It took quite some time debugging into our application to find out the
place where the output difference happens between Tomcat 10.1.39 and
10.1.40:
We're using our own template engine that renders the HTML output,
depending on the actual state of the application for the (logged-in)
user. Basically the code is working the same way as this minimal reproducer:
package com.example;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@WebServlet("/HelloWorld")
public class HelloWorld extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
response.setContentType("text/html; charset=UTF-8");
var resource =
request.getServletContext().getResource("HelloWorld.html");
var connection = resource.openConnection();
String contentType = connection.getContentType();
if (null == contentType) {
contentType = "text/html";
}
var length = connection.getContentLength();
var baos = new ByteArrayOutputStream();
try (var is = connection.getInputStream()) {
is.transferTo(baos);
}
var output = baos.toByteArray();
response.setContentLength(length);
response.setContentType(contentType);
try (var os = response.getOutputStream()) {
os.write(output, 0, output.length);
}
}
}
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1" metadata-complete="true">
<display-name>Hello World Web Application</display-name>
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>com.example.HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
HelloWorld.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
<title>Hello World!</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>
With Tomcat 10.1.39 I'm getting the following result with curl:
%> curl -v http://localhost:8080/hello
(...)
* Request completely sent off
< HTTP/1.1 200
< Content-Type: text/html;charset=UTF-8
< Content-Length: 212
(...)
With Tomcat 10.1.40:
(...)
* Request completely sent off
< HTTP/1.1 200
< Content-Type: content/unknown;charset=UTF-8
< Content-Length: 212
(...)
The reason is exactly what you assumed and the change that Mark mentioned:
Since 10.1.40 the class CachedResource$CachedResourceURLConnection now
has a new method "public String getContentType()" that is causing this
difference...
Ok, we could change our code so that in case the content type is set to
"content/unknown" we're replacing that by "text/html". OTOH with respect
to our customers this isn't really a good solution: On the one hand they
partly have older releases that would have to be patched. On the other
hand we normally don't have control about their environment; we could
only give advises, especially in this case don't upgrade to Tomcat
10.1.40...
WDYT?
Thorsten
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Content type unknown after upgrading Tomcat 10.1.39 => 10.1.40
Posted by Christopher Schultz <ch...@christopherschultz.net>.
Thorsten,
On 4/17/25 1:54 AM, Thorsten Heit wrote:
> Hi Chris,
>
>> That definitely sounds odd. Do you have anything on the network
>> between the client (browser) and the server (Tomcat)? Specifically,
>> anything like a load-balancer, proxy, or similar?
>>
>> I just want to remove other possible causes before diving into Tomcat
>> (but from your description, Tomcat does seem to be the suspicious
>> component, here).
>
> No, there's nothing in between me and Tomcat. It's reproducible also by
> directly using curl on the command line:
>
> "curl -v --insecure --noproxy '*' https://.../" gives me the following
> on 10.1.39 (private data replaced for security):
>
>
> Note: Using embedded CA bundle (233263 bytes)
> Note: Using embedded CA bundle, for proxies (233263 bytes)
> % Total % Received % Xferd Average Speed Time Time Time
> Current
> Dload Upload Total Spent Left
> Speed
> 0 0 0 0 0 0 0 0 --:--:-- --:--:--
> --:--:-- 0* Host myhost.example.com:8448 was resolved.
> * IPv6: 2a02:5a0:f019:1:4448:4350:a9b4:9022
> * IPv4: 10.192.141.7
> * Trying [2a02:5a0:f019:1:4448:4350:a9b4:9022]:8448...
> * ALPN: curl offers h2,http/1.1
> * TLSv1.3 (OUT), TLS handshake, Client hello (1):
> } [317 bytes data]
> * TLSv1.3 (IN), TLS handshake, Server hello (2):
> { [122 bytes data]
> * TLSv1.3 (IN), TLS handshake, Unknown (8):
> { [41 bytes data]
> * TLSv1.3 (IN), TLS handshake, Certificate (11):
> { [5210 bytes data]
> * TLSv1.3 (IN), TLS handshake, CERT verify (15):
> { [520 bytes data]
> * TLSv1.3 (IN), TLS handshake, Finished (20):
> { [52 bytes data]
> * TLSv1.3 (OUT), TLS handshake, Finished (20):
> } [52 bytes data]
> * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 / [blank] / UNDEF
> * ALPN: server accepted h2
> * Server certificate:
> * subject: ...
> * start date: May 6 10:01:48 2024 GMT
> * expire date: Dec 26 10:01:48 2048 GMT
> * issuer: ...
> * SSL certificate verify result: self signed certificate in certificate
> chain (19), continuing anyway.
> * Certificate level 0: Public key type ? (4096/128 Bits/secBits),
> signed using sha256WithRSAEncryption
> * Certificate level 1: Public key type ? (4096/128 Bits/secBits),
> signed using sha256WithRSAEncryption
> * Certificate level 2: Public key type ? (4096/128 Bits/secBits),
> signed using sha512WithRSAEncryption
> * Connected to myhost.example.com (2a02:5a0:f019:1:4448:4350:a9b4:9022)
> port 8448
> * using HTTP/2
> * [HTTP/2] [1] OPENED stream for https://myhost.example.com:8448/my/
> servlet/app?version=!!1.22.32-4-g8a3c060!!
> * [HTTP/2] [1] [:method: GET]
> * [HTTP/2] [1] [:scheme: https]
> * [HTTP/2] [1] [:authority: myhost.example.com:8448]
> * [HTTP/2] [1] [:path: /my/servlet/app?version=!!1.22.32-4-g8a3c060!!]
> * [HTTP/2] [1] [user-agent: curl/8.12.1]
> * [HTTP/2] [1] [accept: */*]
> > GET /my/servlet/app?version=!!1.22.32-4-g8a3c060!! HTTP/2
> > Host: myhost.example.com:8448
> > User-Agent: curl/8.12.1
> > Accept: */*
> >
> * Request completely sent off
> 0 0 0 0 0 0 0 0 --:--:-- --:--:--
> --:--:-- 0< HTTP/2 200
> < cache-control: max-age=0
> < expires: Wed, 16 Apr 2025 16:22:16 GMT
> < content-type: text/html;charset=UTF-8
> < content-length: 7999
> < date: Wed, 16 Apr 2025 16:22:16 GMT
> <
> { [7999 bytes data]
> 100 7999 100 7999 0 0 31126 0 --:--:-- --:--:-- --:--:--
> 31246
> * Connection #0 to host myhost.example.com left intact
>
>
> With 10.1.40 using exactly the same command the result is the same apart
> from the content-type:
>
> (...)
> * Request completely sent off
> 0 0 0 0 0 0 0 0 --:--:-- --:--:--
> --:--:-- 0< HTTP/2 200
> < cache-control: max-age=0
> < expires: Wed, 16 Apr 2025 16:19:48 GMT
> < content-type: content/unknown;charset=UTF-8
> < content-length: 7999
> < date: Wed, 16 Apr 2025 16:19:48 GMT
> <
> { [7999 bytes data]
> 100 7999 100 7999 0 0 32015 0 --:--:-- --:--:-- --:--:--
> 32124
>
>
> This is what's puzzling me...
>
>
> BTW, I'm using a system-wide Tomcat installation under /usr/local/share
> and a user installation with its own ./conf directory; basically the
> same what Ubuntu is offering via the packages "tomcat10-common" and
> "tomcat10-user".
> This way I can switch the Tomcat version to be used by simply changing
> the CATALINA_HOME variable in the startup script. But I guess this
> shouldn't matter...
Tomcat is never going to figure out what MIME type should be used for a
request like "/my/servlet/app?version=!!1.22.32-4-g8a3c060!!"
So I think Mark is probably right (well, he's right like 99.999% of the
time, so...) about this being related to
https://bz.apache.org/bugzilla/show_bug.cgi?id=69623 but I suspect your
servlet is not explicitly setting a content-type.
I would be expecting Tomcat to set a default content-type of text/html
if the servlet does not explicitly set the type. If that's not
happening, it's a spec violation and we will fix it one way or another.
A quick way to fix this would be to edit the servlet or JSP that
generates this response and explicitly set the content-type response
header to "text/html". You could do this with a Filter as well if that's
more convenient, which is likely the case because it would cover all
servlets and not just the one you happen to be testing at the moment.
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Content type unknown after upgrading Tomcat 10.1.39 => 10.1.40
Posted by Thorsten Heit <he...@icloud.com.INVALID>.
Hi Chris,
> That definitely sounds odd. Do you have anything on the network between
> the client (browser) and the server (Tomcat)? Specifically, anything
> like a load-balancer, proxy, or similar?
>
> I just want to remove other possible causes before diving into Tomcat
> (but from your description, Tomcat does seem to be the suspicious
> component, here).
No, there's nothing in between me and Tomcat. It's reproducible also by
directly using curl on the command line:
"curl -v --insecure --noproxy '*' https://.../" gives me the following
on 10.1.39 (private data replaced for security):
Note: Using embedded CA bundle (233263 bytes)
Note: Using embedded CA bundle, for proxies (233263 bytes)
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:--
--:--:-- 0* Host myhost.example.com:8448 was resolved.
* IPv6: 2a02:5a0:f019:1:4448:4350:a9b4:9022
* IPv4: 10.192.141.7
* Trying [2a02:5a0:f019:1:4448:4350:a9b4:9022]:8448...
* ALPN: curl offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
} [317 bytes data]
* TLSv1.3 (IN), TLS handshake, Server hello (2):
{ [122 bytes data]
* TLSv1.3 (IN), TLS handshake, Unknown (8):
{ [41 bytes data]
* TLSv1.3 (IN), TLS handshake, Certificate (11):
{ [5210 bytes data]
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
{ [520 bytes data]
* TLSv1.3 (IN), TLS handshake, Finished (20):
{ [52 bytes data]
* TLSv1.3 (OUT), TLS handshake, Finished (20):
} [52 bytes data]
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 / [blank] / UNDEF
* ALPN: server accepted h2
* Server certificate:
* subject: ...
* start date: May 6 10:01:48 2024 GMT
* expire date: Dec 26 10:01:48 2048 GMT
* issuer: ...
* SSL certificate verify result: self signed certificate in certificate
chain (19), continuing anyway.
* Certificate level 0: Public key type ? (4096/128 Bits/secBits),
signed using sha256WithRSAEncryption
* Certificate level 1: Public key type ? (4096/128 Bits/secBits),
signed using sha256WithRSAEncryption
* Certificate level 2: Public key type ? (4096/128 Bits/secBits),
signed using sha512WithRSAEncryption
* Connected to myhost.example.com (2a02:5a0:f019:1:4448:4350:a9b4:9022)
port 8448
* using HTTP/2
* [HTTP/2] [1] OPENED stream for
https://myhost.example.com:8448/my/servlet/app?version=!!1.22.32-4-g8a3c060!!
* [HTTP/2] [1] [:method: GET]
* [HTTP/2] [1] [:scheme: https]
* [HTTP/2] [1] [:authority: myhost.example.com:8448]
* [HTTP/2] [1] [:path: /my/servlet/app?version=!!1.22.32-4-g8a3c060!!]
* [HTTP/2] [1] [user-agent: curl/8.12.1]
* [HTTP/2] [1] [accept: */*]
> GET /my/servlet/app?version=!!1.22.32-4-g8a3c060!! HTTP/2
> Host: myhost.example.com:8448
> User-Agent: curl/8.12.1
> Accept: */*
>
* Request completely sent off
0 0 0 0 0 0 0 0 --:--:-- --:--:--
--:--:-- 0< HTTP/2 200
< cache-control: max-age=0
< expires: Wed, 16 Apr 2025 16:22:16 GMT
< content-type: text/html;charset=UTF-8
< content-length: 7999
< date: Wed, 16 Apr 2025 16:22:16 GMT
<
{ [7999 bytes data]
100 7999 100 7999 0 0 31126 0 --:--:-- --:--:-- --:--:--
31246
* Connection #0 to host myhost.example.com left intact
With 10.1.40 using exactly the same command the result is the same apart
from the content-type:
(...)
* Request completely sent off
0 0 0 0 0 0 0 0 --:--:-- --:--:--
--:--:-- 0< HTTP/2 200
< cache-control: max-age=0
< expires: Wed, 16 Apr 2025 16:19:48 GMT
< content-type: content/unknown;charset=UTF-8
< content-length: 7999
< date: Wed, 16 Apr 2025 16:19:48 GMT
<
{ [7999 bytes data]
100 7999 100 7999 0 0 32015 0 --:--:-- --:--:-- --:--:--
32124
This is what's puzzling me...
BTW, I'm using a system-wide Tomcat installation under /usr/local/share
and a user installation with its own ./conf directory; basically the
same what Ubuntu is offering via the packages "tomcat10-common" and
"tomcat10-user".
This way I can switch the Tomcat version to be used by simply changing
the CATALINA_HOME variable in the startup script. But I guess this
shouldn't matter...
Regards
Thorsten
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Content type unknown after upgrading Tomcat 10.1.39 => 10.1.40
Posted by Christopher Schultz <ch...@christopherschultz.net>.
Thorsten,
On 4/16/25 2:35 PM, Thorsten Heit wrote:
> long time Tomcat user, but first time I'm posting, so hi to you all :-)
>
> I'm suffering a strange phenomenon after I upgraded Tomcat on one of our
> virtual machines from 10.1.39 to 10.1.40:
>
> When I open the link to an application being served by Tomcat my browser
> (Firefox) now downloads a file instead of displaying the (generated)
> HTML page. With the network inspector I discovered that the content-type
> in the response is set to "content/unknown;charset=UTF-8". When
> reverting back to 10.1.39 everything works; the content-type in the
> response is (as expected) "text/html;charset=UTF-8".
>
> In the changelog I haven't seen anything regarding this.
>
> The configuration files used to start Tomcat are exactly the same in
> both scenarios, and the application isn't changed.
>
> Can anyone explain what's happening?
>
> Tomcat: 10.1.39 / 40
> Java: openjdk-21.0.6
> OS: Ubuntu 24.04.2 LTS
That definitely sounds odd. Do you have anything on the network between
the client (browser) and the server (Tomcat)? Specifically, anything
like a load-balancer, proxy, or similar?
I just want to remove other possible causes before diving into Tomcat
(but from your description, Tomcat does seem to be the suspicious
component, here).
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org