Getting: bad response on HttpConnectionOverHTTP, Illegal character SPACE=' '

It appears the http binding is choking on a space in an HTTP response. I can curl the same URL from the OpenHab cli or from any browser, and view the HTML stream, so I assumed it was some kind of non-compliance in the endpoint prior to returning the payload/string.

Thus, I compared the PCAP from OH vs curl, Firefox, they look functionally the same, that is, the string containing the HTML is actually being returned in the TCP stream (i.e. OH doesn’t seem to be choking prior).

2021-06-26 13:21:15.585 [INFO ] [nding.http.internal.HttpThingHandler] - Using the secure client for thing 'http:url:7e16d949c3'.
2021-06-26 13:21:16.626 [WARN ] [p.internal.http.HttpResponseListener] - Requesting '' (method='GET', content='null') failed: HTTP protocol violation: bad response on HttpConnectionOverHTTP@18d9b89::SocketChannelEndPoint@1073d69{l=/,r=/,OPEN,fill=-,flush=-,to=2/0}{io=0/0,kio=0,kro=1}->HttpConnectionOverHTTP@18d9b89(l:/ <-> r:/,closed=false)=>HttpChannelOverHTTP@632db2(exchange=HttpExchange@e920c4{req=HttpRequest[GET /cmSignalData.htm HTTP/1.1]@185b9c3[TERMINATED/null] res=HttpResponse[HTTP/1.0 400 Illegal character SPACE=' ']@1e33c2f[PENDING/null]})[send=HttpSenderOverHTTP@4e829c(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@1327491{s=START}],recv=HttpReceiverOverHTTP@1b39555(rsp=HEADER,failure=null)[HttpParser{s=CLOSE,0 of -1}]]

To simplify the response, I created a simple REGEX transformation that substitutes the entire response into a single string (I validated the Regex substitution outside of OH for good measure)

Can anyone suggest a workaround or maybe there’s a HTTP binding bug? I can share PCAP files if that’s helpful.

FWIW: The endpoint is an Arris/Surfboard cablemodem with a UI based in the stone age (LoL: Created with Frontpage 4.0!! :slight_smile: ). The cablemodem itself isn’t old, but the GUI code is ancient, so I wouldn’t be surprised if it’s breaking compliance in some way.

Could be an issue with one of the headers. Can you show the headers? Or send the pcap via PM.

PM’d you. Thank you!

I opened the PCAP with wireshark and it immediately shows an error on the Cache-Control header:

Frame 16: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)
Ethernet II, Src: PCEngine_xx:xx:xx (xx:xx:xx:xx:xx:xx), Dst: Raspberr_xx:xx:xx (xx:xx:xx:xx:xx:xx)
Internet Protocol Version 4, Src:, Dst:
Transmission Control Protocol, Src Port: 80, Dst Port: 40822, Seq: 5123, Ack: 94, Len: 0
[6 Reassembled TCP Segments (5122 bytes): #6(206), #8(1448), #10(1448), #12(1448), #14(572), #16(0)]
Hypertext Transfer Protocol
    HTTP/1.0 200 Ok\r\n
    Server: NET-DK/1.0\r\n
    X-Frame-Options: SAMEORIGIN\r\n
    Date: Sat, 26 Jun 2021 12:50:00 GMT\r\n
    Cache-Control : no-cache\r\n
        [Expert Info (Warning/Protocol): Illegal characters found in header name]
            [Illegal characters found in header name]
            [Severity level: Warning]
            [Group: Protocol]
    Pragma: no-cache\r\n
    Expires: -1\r\n
    Content-Type: text/html\r\n
    Connection: close\r\n
    [HTTP response 1/1]
    [Time since request: 0.811461000 seconds]
    [Request in frame: 4]
    [Request URI:]
    File Data: 4916 bytes

So this is the same error that Jetty reports. The space before the colon is not allowed (RFC 2616, sec. 4.2). Unfortunately I have no solution for you, I’m not aware of a method to disable the checks in Jetty. A workaround maybe to use nginx or Apache as a proxy and rewrite/strip the header,

1 Like

Ah, I see it now too. I was expecting WS to flag the entire packet as it does for some error types. I now see the highlighted header when I dig down. Now let me just file a bug report with Arris… Kidding.

My only goal is to periodically fetch that cmSignalData.htm page to see if the numbers are growing (i.e. to check whether signal is deteriorating, e.g. water ingress / squirrels chewing) to give myself the opportunity to fix it before it creates disruption.

Do you have an opinion on whether it would be simpler to use cron and curl, or possibly the Openhab TCP binding? Really all I need to do is barf a GET request at my CableModem, and scrape the frontpage-barfed reply (table) for uncorrectable error counts. No inputs or parameters ever.

I personally use executeCommandLine resp. the execbinding in case I need to get values from a shell(script). E.g. items that I am not not able to do quick with OH internals I am doing in shell scripts.
As you already seem to know how to use curl to get the value you are already half way.