-
Bug
-
Resolution: Done
-
Blocker
-
fuse-next-TP1-CR2
TLDR: using the URLs returned in odata responses for new requests in apache http client causes 406 in the server pod because it tries to add the port twice to the url
The current implementation of odata endpoint always adds the port to the returned links (such as context or nextLink), even when using the default port and not specifying it in the request:
$ curl -s -k https://olingo-1-asmigala-fdf.apps.dv-43-a.openshift-aws.rhocf-dev.com/odata/Source/SimpleTableView | jq '."@odata.context"' "https://olingo-1-asmigala-fdf.apps.dv-43-a.openshift-aws.rhocf-dev.com:443/odata/Source/$metadata#SimpleTableView"
This is ok, but will be important for triggering the issue later.
Tools such as curl or web browsers strip the port from the hostname before they set it in the Host header on the HTTP request:
$ curl -vs -k https://olingo-1-asmigala-fdf.apps.dv-43-a.openshift-aws.rhocf-dev.com/odata/Source/SimpleTableView 2>&1 | grep 'Host:'
> Host: olingo-1-asmigala-fdf.apps.dv-43-a.openshift-aws.rhocf-dev.com
However, the Apache HTTP client java client (also used by the olingo odata 4 client) does not strip the port, resulting in Host header such as
Host: olingo-1-asmigala-fdf.apps.dv-43-a.openshift-aws.rhocf-dev.com:443
This is in fact in line with RFC 2616 which states
The Host request-header field specifies the Internet host and port
number of the resource being requested, as obtained from the original
URI given by the user or referring resource
Requests with such a header will fail in the vdb pod with the following exception:
Caused by: java.lang.RuntimeException: Unable to create URI: https://olingo-1-asmigala-fdf.apps.dv-43-a.openshift-aws.rhocf-dev.com:443:443/odata/Source/SimpleTableView at org.teiid.olingo.web.ProxyHttpServletRequest.<init>(ProxyHttpServletRequest.java:85) ~[teiid-olingo-13.1.1.fuse-jdk11-800015-redhat-00001.jar!/:13.1.1.fuse-jdk11-800015-redhat-00001] at org.teiid.spring.odata.SpringODataFilter.handleProxiedRequest(SpringODataFilter.java:218) ~[spring-odata-1.4.1.fuse-jdk11-800012-redhat-00001.jar!/:1.4.1.fuse-jdk11-800012-redhat-00001] at org.teiid.spring.odata.SpringODataFilter.preHandle(SpringODataFilter.java:73) ~[spring-odata-1.4.1.fuse-jdk11-800012-redhat-00001.jar!/:1.4.1.fuse-jdk11-800012-redhat-00001] at org.springframework.web.servlet.HandlerExecutionChain.applyPreHandle(HandlerExecutionChain.java:136) ~[spring-webmvc-5.1.8.RELEASE.jar!/:5.1.8.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1034) ~[spring-webmvc-5.1.8.RELEASE.jar!/:5.1.8.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) ~[spring-webmvc-5.1.8.RELEASE.jar!/:5.1.8.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) ~[spring-webmvc-5.1.8.RELEASE.jar!/:5.1.8.RELEASE] ... 66 common frames omitted Caused by: java.net.MalformedURLException: Error at index 3 in: "443:443" at java.base/java.net.URL.<init>(URL.java:679) ~[na:na] at java.base/java.net.URL.<init>(URL.java:541) ~[na:na] at java.base/java.net.URL.<init>(URL.java:488) ~[na:na] at org.teiid.olingo.web.ProxyHttpServletRequest.<init>(ProxyHttpServletRequest.java:83) ~[teiid-olingo-13.1.1.fuse-jdk11-800015-redhat-00001.jar!/:13.1.1.fuse-jdk11-800015-redhat-00001] ... 72 common frames omitted
Notice 443:443, it appears the backend is trying to add the port even though it's already there, which makes the resulting URL invalid.
- is cloned by
-
TEIID-5942 OData request fails when Host header specifies also port
- Resolved