Modifying the HTTP/1.1 Response Status Line's HTTP Version indicator

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Modifying the HTTP/1.1 Response Status Line's HTTP Version indicator

Karel Goderis
Hi all

I am implementing the Apple Home Accessory Protocol on top of Jetty 9.3.x. HAP defines a notification/eventing mechanism on top of HTTP

The spec states:

"The accessory delivers notifications by sending an event message, which is an unsolicited HTTP response, over the TCP connection established by the controller. An event message has the same format as an HTTP response, but uses an protocol version of EVENT/1.0.”

Question: how can the version indicator be changed?

My initial though was to write an extension of HttpConnection, and override newHttpGenerator() with a custom HttpGenerator (which is most probably a copy/past from Jetty's built-in HttpGenerator except for that fact that generateResponse() might use a different generateResponseLine() in function of the presence or absence of a to-be-defined X-... Header. I would set that Header in the Handler/Servlet's doHandle() whenever the protocol has to be “switched"

Thanks
Karel.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Modifying the HTTP/1.1 Response Status Line's HTTP Version indicator

Joakim Erdfelt-8
Are you using the Jetty HttpClient and want to see these unsolicited HAP responses?
Or are you wanting to generate these unsolicited responses on the Jetty server side?

Using something newer then Jetty 9.3.x might be a better option.
Jetty 9.4.x, or if your schedule permits it, Jetty 10.0.x could bend/modify to support something like this (while Jetty 9.x is less flexible ATM).

Joakim Erdfelt / [hidden email]


On Thu, Nov 7, 2019 at 10:57 AM Karel Goderis <[hidden email]> wrote:
Hi all

I am implementing the Apple Home Accessory Protocol on top of Jetty 9.3.x. HAP defines a notification/eventing mechanism on top of HTTP

The spec states:

"The accessory delivers notifications by sending an event message, which is an unsolicited HTTP response, over the TCP connection established by the controller. An event message has the same format as an HTTP response, but uses an protocol version of EVENT/1.0.”

Question: how can the version indicator be changed?

My initial though was to write an extension of HttpConnection, and override newHttpGenerator() with a custom HttpGenerator (which is most probably a copy/past from Jetty's built-in HttpGenerator except for that fact that generateResponse() might use a different generateResponseLine() in function of the presence or absence of a to-be-defined X-... Header. I would set that Header in the Handler/Servlet's doHandle() whenever the protocol has to be “switched"

Thanks
Karel.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Modifying the HTTP/1.1 Response Status Line's HTTP Version indicator

Karel Goderis
I am using the server, and I need to generate these answers to clients connecting to the server. 

The project currently has a dependency on 9.3.25, however, since it is a collection of OSGi bundles, I think that I can incorporate a dependency on 9.4 or 10, but I am not sure how that will fare with the rest of the contributors. I checked 10.0.0 and it is not yet released, so I will fall back on 9.4.x. What would be a sensible approach on 9.4 (or 9.3) to achieve this?

K

On 7 Nov 2019, at 18:05, Joakim Erdfelt <[hidden email]> wrote:

Are you using the Jetty HttpClient and want to see these unsolicited HAP responses?
Or are you wanting to generate these unsolicited responses on the Jetty server side?

Using something newer then Jetty 9.3.x might be a better option.
Jetty 9.4.x, or if your schedule permits it, Jetty 10.0.x could bend/modify to support something like this (while Jetty 9.x is less flexible ATM).

Joakim Erdfelt / [hidden email]


On Thu, Nov 7, 2019 at 10:57 AM Karel Goderis <[hidden email]> wrote:
Hi all

I am implementing the Apple Home Accessory Protocol on top of Jetty 9.3.x. HAP defines a notification/eventing mechanism on top of HTTP

The spec states:

"The accessory delivers notifications by sending an event message, which is an unsolicited HTTP response, over the TCP connection established by the controller. An event message has the same format as an HTTP response, but uses an protocol version of EVENT/1.0.”

Question: how can the version indicator be changed?

My initial though was to write an extension of HttpConnection, and override newHttpGenerator() with a custom HttpGenerator (which is most probably a copy/past from Jetty's built-in HttpGenerator except for that fact that generateResponse() might use a different generateResponseLine() in function of the presence or absence of a to-be-defined X-... Header. I would set that Header in the Handler/Servlet's doHandle() whenever the protocol has to be “switched"

Thanks
Karel.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Modifying the HTTP/1.1 Response Status Line's HTTP Version indicator

Simone Bordet-3
Hi,

On Thu, Nov 7, 2019 at 6:28 PM Karel Goderis <[hidden email]> wrote:
>
> I am using the server, and I need to generate these answers to clients connecting to the server.
>
> The project currently has a dependency on 9.3.25, however, since it is a collection of OSGi bundles, I think that I can incorporate a dependency on 9.4 or 10, but I am not sure how that will fare with the rest of the contributors. I checked 10.0.0 and it is not yet released, so I will fall back on 9.4.x. What would be a sensible approach on 9.4 (or 9.3) to achieve this?
>

jetty-9.4.x is the branch to use.

This unsolicited answer, does it happen only at connection
initialization, or may happen after a HTTP response?

If the former, you can look at ProxyConnectionFactory, where we handle
the PROXY protocol before delegating to another connection.

If it happens after normal HTTP responses, it's the weirdest use of a
protocol I've seen so far.

Your best option would be to queue those events, and register for
HttpChannel events.
When you have a "complete" event for a HTTP request/response, you can
grab your events from the queue and use the EndPoint to manually write
them out.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Modifying the HTTP/1.1 Response Status Line's HTTP Version indicator

Karel Goderis
That’s Apple :-)

It happens after normal responses. I will have a look at your suggestion and get back to you

Tx
K

Sent from my iPhone

> On 7 Nov 2019, at 19:10, Simone Bordet <[hidden email]> wrote:
>
> Hi,
>
>> On Thu, Nov 7, 2019 at 6:28 PM Karel Goderis <[hidden email]> wrote:
>>
>> I am using the server, and I need to generate these answers to clients connecting to the server.
>>
>> The project currently has a dependency on 9.3.25, however, since it is a collection of OSGi bundles, I think that I can incorporate a dependency on 9.4 or 10, but I am not sure how that will fare with the rest of the contributors. I checked 10.0.0 and it is not yet released, so I will fall back on 9.4.x. What would be a sensible approach on 9.4 (or 9.3) to achieve this?
>>
>
> jetty-9.4.x is the branch to use.
>
> This unsolicited answer, does it happen only at connection
> initialization, or may happen after a HTTP response?
>
> If the former, you can look at ProxyConnectionFactory, where we handle
> the PROXY protocol before delegating to another connection.
>
> If it happens after normal HTTP responses, it's the weirdest use of a
> protocol I've seen so far.
>
> Your best option would be to queue those events, and register for
> HttpChannel events.
> When you have a "complete" event for a HTTP request/response, you can
> grab your events from the queue and use the EndPoint to manually write
> them out.
>
> --
> Simone Bordet
> ----
> http://cometd.org
> http://webtide.com
> Developer advice, training, services and support
> from the Jetty & CometD experts.
> _______________________________________________
> jetty-users mailing list
> [hidden email]
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Modifying the HTTP/1.1 Response Status Line's HTTP Version indicator

Karel Goderis
In reply to this post by Simone Bordet-3
Hi Simone

Since these events are in fact normal HTTP messages, with a different version string, is there a way to leverage the built-in jetty classes to create, … these messages, before they are fed to the Enpoint? The Enpoint is a very low-level class, and I do not want to “craft” bytebyffer by hand for these messages
I also noticed that the methods in the interface that are used to add listeners are depreciated in 9.4.x. So, how to go around that?  The other thing I am not quite sure about is how to get hold of the right HttpChannel that goes with the intended remote end

Any pointer to an example of HttpChannel.Listener would be helpful. Google is not my best friend with respect to this…

Thanks
Karel

> On 7 Nov 2019, at 19:09, Simone Bordet <[hidden email]> wrote:
>
> Hi,
>
> On Thu, Nov 7, 2019 at 6:28 PM Karel Goderis <[hidden email]> wrote:
>>
>> I am using the server, and I need to generate these answers to clients connecting to the server.
>>
>> The project currently has a dependency on 9.3.25, however, since it is a collection of OSGi bundles, I think that I can incorporate a dependency on 9.4 or 10, but I am not sure how that will fare with the rest of the contributors. I checked 10.0.0 and it is not yet released, so I will fall back on 9.4.x. What would be a sensible approach on 9.4 (or 9.3) to achieve this?
>>
>
> jetty-9.4.x is the branch to use.
>
> This unsolicited answer, does it happen only at connection
> initialization, or may happen after a HTTP response?
>
> If the former, you can look at ProxyConnectionFactory, where we handle
> the PROXY protocol before delegating to another connection.
>
> If it happens after normal HTTP responses, it's the weirdest use of a
> protocol I've seen so far.
>
> Your best option would be to queue those events, and register for
> HttpChannel events.
> When you have a "complete" event for a HTTP request/response, you can
> grab your events from the queue and use the EndPoint to manually write
> them out.
>
> --
> Simone Bordet
> ----
> http://cometd.org
> http://webtide.com
> Developer advice, training, services and support
> from the Jetty & CometD experts.
> _______________________________________________
> jetty-users mailing list
> [hidden email]
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Modifying the HTTP/1.1 Response Status Line's HTTP Version indicator

Simone Bordet-3
Hi,

On Fri, Nov 8, 2019 at 10:03 AM Karel Goderis <[hidden email]> wrote:
>
> Hi Simone
>
> Since these events are in fact normal HTTP messages,

Well, they are not, otherwise there would be nothing to modify :)

> with a different version string, is there a way to leverage the built-in jetty classes to create, … these messages, before they are fed to the Enpoint?

Not right now, but the relevant classes may be modified to accommodate
that. PR from you?

> The Enpoint is a very low-level class, and I do not want to “craft” bytebyffer by hand for these messages

Why not? The textual format of HTTP/1.1 would make this really easy.
You concatenate a String, get the bytes, then EndPoint.write().

> I also noticed that the methods in the interface that are used to add listeners are depreciated in 9.4.x. So, how to go around that?  The other thing I am not quite sure about is how to get hold of the right HttpChannel that goes with the intended remote end
>
> Any pointer to an example of HttpChannel.Listener would be helpful. Google is not my best friend with respect to this…

https://github.com/eclipse/jetty.project/blob/jetty-9.4.22.v20191022/jetty-server/src/test/java/org/eclipse/jetty/server/HttpChannelEventTest.java

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users