Bug 343018 - Jetty does not recognize internationalized (IDN) SUB domain names
Summary: Jetty does not recognize internationalized (IDN) SUB domain names
Status: RESOLVED WORKSFORME
Alias: None
Product: Jetty
Classification: RT
Component: server (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: 7.2.x   Edit
Assignee: Greg Wilkins CLA
QA Contact:
URL: http://XN--80AHAIUUGL4G.citadelait.com
Whiteboard:
Keywords: core, greatbug
Depends on: 319057
Blocks:
  Show dependency tree
 
Reported: 2011-04-15 15:55 EDT by Boris Hamanov CLA
Modified: 2011-05-10 04:03 EDT (History)
3 users (show)

See Also:


Attachments
Complete session log (376.54 KB, text/plain)
2011-04-16 06:26 EDT, Boris Hamanov CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Boris Hamanov CLA 2011-04-15 15:55:40 EDT
Build Identifier: 7.3.1.v20110307

The international form of my sub domain name is like this: XN--80AHAIUUGL4G

It is properly setup in my provider and resolves. That is tested.

My top-level domain name is citadelait.com so I wrote in jetty virtual hosts: XN--80AHAIUUGL4G.citadelait.com

However, it does not work, when I try to access my web page I am redirected to my normal web site www.citadelait.com (This is because I have setup MovedContextHandler that handles all virtual hosts that do not match the default and redirects to www.citadelait.com)

See in my default context below:

> poddruvka.citadelait.com WORKS
> www.citadelait.com WORKS
> XN--80AHAIUUGL4G.citadelait.com DOES NOT work

This paper here: http://wiki.eclipse.org/Jetty/Howto/Configure_Virtual_Hosts says it should (Although the example is for the main domain, but there should not be any difference) Here is an example of IDN sub domain that works perfectly: http://xn--2z1b67o3qg.blogspot.com/

<?xml version="1.0"  encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.eclipse.org/configure.dtd">

<Configure class="org.eclipse.jetty.servlet.ServletContextHandler">
  <Set name="contextPath">/</Set>
  <Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/webroot/</Set>
  <Set name="virtualHosts">
    <Array type="java.lang.String">
      <Item>www.citadelait.com</Item>
      <Item>XN--80AHAIUUGL4G.citadelait.com</Item>
      <Item>poddruvka.citadelait.com</Item>
    </Array>
  </Set>

Reproducible: Always

Steps to Reproduce:
1.Enter IDN name in virtual hosts context configuration
2.Try to access the host with the IDN name
3.Jetty does not recognize it
Comment 1 Jan Bartel CLA 2011-04-15 18:41:54 EDT
Boris, 

Have a read of https://bugs.eclipse.org/bugs/show_bug.cgi?id=319057

How are you trying to access the url? If in the browser, then you should type in the non-encoded form of the name. In your case that is:

http://поддръжка.citadelait.com

If that's what you're doing, can you capture a tcpdump/wireshark trace of the http dialog with jetty, and ensure you have DEBUG enabled and send the relevant sections of the jetty log file.

thanks
Jan
Comment 2 Boris Hamanov CLA 2011-04-16 06:26:24 EDT
Created attachment 193413 [details]
Complete session log
Comment 3 Boris Hamanov CLA 2011-04-16 06:27:25 EDT
I read https://bugs.eclipse.org/bugs/show_bug.cgi?id=319057 It seems that I do everything correctly.
Indeed, it would be nicer to use the original form of the url. Thanks for that guys, I will use it when it is ready.

I tried using both 

http://поддръжка.citadelait.com and http://xn--80ahaiuugl4g.citadelait.com NOTHING works

This is the log from fidler2


GET http://xn--80ahaiuugl4g.citadelait.com/ HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: en-US,bg-BG;q=0.5
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: xn--80ahaiuugl4g.citadelait.com

HTTP/1.1 301 Moved Permanently
Date: Sat, 16 Apr 2011 08:13:54 GMT
Location: http://www.citadelait.com/
Content-Length: 0


This is the jetty debug log about that particular request. I will atach the complete session log


16 IV 2011 13:16:48,704 [qtp2106232034-25 - /] DEBUG org.eclipse.jetty.util.log  - REQUEST / on org.eclipse.jetty.server.nio.SelectChannelConnector$2@ee31e33
16 IV 2011 13:16:48,706 [qtp2106232034-25 - /] DEBUG org.eclipse.jetty.util.log  - servlet=org.eclipse.jetty.servlet.DefaultServlet-1388314661
16 IV 2011 13:16:48,706 [qtp2106232034-25 - /] DEBUG org.eclipse.jetty.util.log  - servlet holder=
16 IV 2011 13:16:48,706 [qtp2106232034-25 - /] DEBUG org.eclipse.jetty.util.log  - chain=
16 IV 2011 13:16:48,711 [qtp2106232034-25 - /] DEBUG org.eclipse.jetty.util.log  - resource base = null
16 IV 2011 13:16:48,711 [qtp2106232034-25 - /] DEBUG org.eclipse.jetty.util.log  - RESOURCE /=file:/C:/jetty/webroot/
16 IV 2011 13:16:48,712 [qtp2106232034-25 - /] DEBUG org.eclipse.jetty.util.log  - uri=/ resource=file:/C:/jetty/webroot/ content
16 IV 2011 13:16:48,713 [qtp2106232034-25 - /] DEBUG org.eclipse.jetty.util.log  - RESOURCE /index.html=file:/C:/jetty/webroot/index.html
16 IV 2011 13:16:48,713 [qtp2106232034-25 - /] DEBUG org.eclipse.jetty.util.log  - welcome=index.html
16 IV 2011 13:16:48,715 [qtp2106232034-25 - /] DEBUG org.eclipse.jetty.util.log  - servlet=org.eclipse.jetty.servlet.DefaultServlet-1388314661
16 IV 2011 13:16:48,715 [qtp2106232034-25 - /] DEBUG org.eclipse.jetty.util.log  - servlet holder=
16 IV 2011 13:16:48,715 [qtp2106232034-25 - /] DEBUG org.eclipse.jetty.util.log  - chain=
16 IV 2011 13:16:48,716 [qtp2106232034-25 - /] DEBUG org.eclipse.jetty.util.log  - RESOURCE /index.html.gz=file:/C:/jetty/webroot/index.html.gz
16 IV 2011 13:16:48,717 [qtp2106232034-25 - /] DEBUG org.eclipse.jetty.util.log  - uri=/index.html resource=file:/C:/jetty/webroot/index.html.gz content
16 IV 2011 13:16:48,719 [qtp2106232034-25 - /] DEBUG org.eclipse.jetty.util.log  - RESPONSE /  304
Comment 4 Boris Hamanov CLA 2011-04-16 06:38:20 EDT
Additional note: I have removed UTF-8 encoding from my default.xml (default context) I added that in the hope that the unicode coded form (поддръжка) will work. It did not, so I reverted it back to ISO-8859-1. Anyway why Jetty fails to handle plain ANSI domain name is beyond me. Maybe the "--" part bothers it somehow? Can you reproduce that on your side? Does the top level IDN domain name work in this Jetty version?
Comment 5 Greg Wilkins CLA 2011-05-10 04:03:54 EDT
I just added your domain to the ManyContexts example and used telnet to send the following request:

GET http://xn--80ahaiuugl4g.citadelait.com/context/foobar  HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: en-US,bg-BG;q=0.5
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64;
Trident/5.0)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: xn--80ahaiuugl4g.citadelait.com



to which I got the response:


HTTP/1.1 200 OK
Content-Type: text/html;charset=UTF-8
Content-Length: 188
Server: Jetty(7.x.y-SNAPSHOT)

<h1>A Virtual Context</h1>
<a href='/'>root context</a><br/><a href='http://127.0.0.1:8080/context'>normal context</a><br/><a href='http://127.0.0.2:8080/context'>virtual context</a><br/>


So the virtual host mechanism does look to be working.

Can you look at ManyContexts example and convert that into a test that fails for you. Then reopen this issue with that test attached.