You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "NavidJalali (via GitHub)" <gi...@apache.org> on 2024/10/23 19:53:36 UTC

[PR] Fix partial match [pekko-http]

NavidJalali opened a new pull request, #622:
URL: https://github.com/apache/pekko-http/pull/622

   I hit this case in a test and it threw. I am not sure if when `trailer.headers` is empty, it should return None or a parsed frame with empty headers but I figured the guard was there for a reason


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #622:
URL: https://github.com/apache/pekko-http/pull/622#issuecomment-2434884418

   @mdedetrich this looks useful to backport to 1.0.x - wdyt?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #622:
URL: https://github.com/apache/pekko-http/pull/622#discussion_r1814675239


##########
http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRenderingSpec.scala:
##########
@@ -13,14 +13,14 @@
 
 package org.apache.pekko.http.impl.engine.http2
 
+import com.typesafe.config.ConfigFactory
 import java.time.format.DateTimeFormatter
 import org.apache.pekko
+import pekko.http.scaladsl.settings.{ ClientConnectionSettings, ServerSettings }

Review Comment:
   this should be put with the other pekko.http imports



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "NavidJalali (via GitHub)" <gi...@apache.org>.
NavidJalali commented on code in PR #622:
URL: https://github.com/apache/pekko-http/pull/622#discussion_r1814671185


##########
http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRenderingSpec.scala:
##########
@@ -147,21 +145,39 @@ class HttpMessageRenderingSpec extends AnyWordSpec with Matchers {
       value1.exists(_._1 == "date") shouldBe false
     }
 
+    "handle empty trailer" in {
+      val config = ConfigFactory.load("reference.conf")
+      Try {
+        val rendering = new RequestRendering(ClientConnectionSettings(config), NoLogging)
+        rendering(HttpRequest().withAttributes(Map(AttributeKeys.trailer -> Trailer())))
+      }.isSuccess shouldBe true
+      Try {
+        val rendering = new ResponseRendering(ServerSettings(config), NoLogging, dateHeaderRendering)
+        rendering(
+          HttpResponse().withAttributes(
+            Map(
+              AttributeKeys.trailer -> Trailer(),
+              Http2.streamId -> 0)))
+      }.isSuccess shouldBe true
+    }
+
   }
 
-  private def renderClientHeaders(headers: immutable.Seq[HttpHeader], builder: VectorBuilder[(String, String)],

Review Comment:
   I think IntelliJ is deleting the Seq import, thinking its useless



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #622:
URL: https://github.com/apache/pekko-http/pull/622#issuecomment-2434886831

   @raboof this relates to https://github.com/apache/pekko-grpc/pull/391


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "NavidJalali (via GitHub)" <gi...@apache.org>.
NavidJalali commented on code in PR #622:
URL: https://github.com/apache/pekko-http/pull/622#discussion_r1814668747


##########
http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRenderingSpec.scala:
##########
@@ -147,21 +145,39 @@ class HttpMessageRenderingSpec extends AnyWordSpec with Matchers {
       value1.exists(_._1 == "date") shouldBe false
     }
 
+    "handle empty trailer" in {
+      val config = ConfigFactory.load("reference.conf")
+      Try {
+        val rendering = new RequestRendering(ClientConnectionSettings(config), NoLogging)
+        rendering(HttpRequest().withAttributes(Map(AttributeKeys.trailer -> Trailer())))
+      }.isSuccess shouldBe true
+      Try {
+        val rendering = new ResponseRendering(ServerSettings(config), NoLogging, dateHeaderRendering)
+        rendering(
+          HttpResponse().withAttributes(
+            Map(
+              AttributeKeys.trailer -> Trailer(),
+              Http2.streamId -> 0)))
+      }.isSuccess shouldBe true
+    }
+
   }
 
-  private def renderClientHeaders(headers: immutable.Seq[HttpHeader], builder: VectorBuilder[(String, String)],

Review Comment:
   Yeah interesting in the CI it failed for 2.12 tho, saying its an unexpected type



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "NavidJalali (via GitHub)" <gi...@apache.org>.
NavidJalali commented on code in PR #622:
URL: https://github.com/apache/pekko-http/pull/622#discussion_r1814683073


##########
http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRenderingSpec.scala:
##########
@@ -13,14 +13,14 @@
 
 package org.apache.pekko.http.impl.engine.http2
 
+import com.typesafe.config.ConfigFactory
 import java.time.format.DateTimeFormatter
 import org.apache.pekko
+import pekko.http.scaladsl.settings.{ ClientConnectionSettings, ServerSettings }
 import pekko.event.NoLogging
 import pekko.http.impl.engine.rendering.DateHeaderRendering
 import pekko.http.scaladsl.model.headers._
-import pekko.http.scaladsl.model.{ ContentTypes, DateTime, HttpHeader, TransferEncodings }
-
-import scala.collection.immutable.Seq
+import pekko.http.scaladsl.model._

Review Comment:
   I was a bit too slow 😄 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning merged PR #622:
URL: https://github.com/apache/pekko-http/pull/622


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #622:
URL: https://github.com/apache/pekko-http/pull/622#discussion_r1814673625


##########
http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRenderingSpec.scala:
##########
@@ -147,21 +145,39 @@ class HttpMessageRenderingSpec extends AnyWordSpec with Matchers {
       value1.exists(_._1 == "date") shouldBe false
     }
 
+    "handle empty trailer" in {
+      val config = ConfigFactory.load("reference.conf")
+      Try {
+        val rendering = new RequestRendering(ClientConnectionSettings(config), NoLogging)
+        rendering(HttpRequest().withAttributes(Map(AttributeKeys.trailer -> Trailer())))
+      }.isSuccess shouldBe true
+      Try {
+        val rendering = new ResponseRendering(ServerSettings(config), NoLogging, dateHeaderRendering)
+        rendering(
+          HttpResponse().withAttributes(
+            Map(
+              AttributeKeys.trailer -> Trailer(),
+              Http2.streamId -> 0)))
+      }.isSuccess shouldBe true
+    }
+
   }
 
-  private def renderClientHeaders(headers: immutable.Seq[HttpHeader], builder: VectorBuilder[(String, String)],

Review Comment:
   it's not useless - add it back



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #622:
URL: https://github.com/apache/pekko-http/pull/622#issuecomment-2434883477

   Thanks @NavidJalali - merging


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "NavidJalali (via GitHub)" <gi...@apache.org>.
NavidJalali commented on PR #622:
URL: https://github.com/apache/pekko-http/pull/622#issuecomment-2434686242

   @pjfanning can you take another look when you get the time?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #622:
URL: https://github.com/apache/pekko-http/pull/622#discussion_r1814680907


##########
http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRenderingSpec.scala:
##########
@@ -13,14 +13,14 @@
 
 package org.apache.pekko.http.impl.engine.http2
 
+import com.typesafe.config.ConfigFactory
 import java.time.format.DateTimeFormatter
 import org.apache.pekko
+import pekko.http.scaladsl.settings.{ ClientConnectionSettings, ServerSettings }
 import pekko.event.NoLogging
 import pekko.http.impl.engine.rendering.DateHeaderRendering
 import pekko.http.scaladsl.model.headers._
-import pekko.http.scaladsl.model.{ ContentTypes, DateTime, HttpHeader, TransferEncodings }
-
-import scala.collection.immutable.Seq
+import pekko.http.scaladsl.model._

Review Comment:
   I've committed a change to the PR branch to try to order the imports



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "raboof (via GitHub)" <gi...@apache.org>.
raboof commented on code in PR #622:
URL: https://github.com/apache/pekko-http/pull/622#discussion_r1814709584


##########
http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRendering.scala:
##########
@@ -99,7 +99,7 @@ private[http2] sealed abstract class MessageRendering[R <: HttpMessage] extends
       r.attribute(AttributeKeys.trailer) match {
         case Some(trailer) if trailer.headers.nonEmpty =>
           OptionVal.Some(ParsedHeadersFrame(streamId, endStream = true, trailer.headers, None))
-        case None => OptionVal.None
+        case _ => OptionVal.None

Review Comment:
   So the question here is if someone added a `AttributeKeys.trailer` but it contained no headers, should we produce a `ParsedHeadersFrame` here? Looking at `Http2SubStream`/`OutStreamImpl`, it does seem safe (it will produce an empty `DataFrame` with `endStream = true` if necessary). It seems unlikely that any downstream implementation would rely on receiving an empty frame of trailing headers.
   
   All in all I think this is OK, though adding a `AttributeKeys.trailer` without any headers seems strange, the code that caused that might deserve a closer look.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "NavidJalali (via GitHub)" <gi...@apache.org>.
NavidJalali commented on PR #622:
URL: https://github.com/apache/pekko-http/pull/622#issuecomment-2433324076

   @pjfanning I am honestly not sure what this code is really doing so I am a bit hesitant to assert things about this. I will have a look at the related tests to see if I can confidently test it


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #622:
URL: https://github.com/apache/pekko-http/pull/622#issuecomment-2433320784

   * seems sensible to change this
   * is there an easy way to get to add a unit test?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "mdedetrich (via GitHub)" <gi...@apache.org>.
mdedetrich commented on code in PR #622:
URL: https://github.com/apache/pekko-http/pull/622#discussion_r1814568594


##########
http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRenderingSpec.scala:
##########
@@ -13,14 +13,14 @@
 
 package org.apache.pekko.http.impl.engine.http2
 
+import com.typesafe.config.ConfigFactory
 import java.time.format.DateTimeFormatter
 import org.apache.pekko
+import org.apache.pekko.http.scaladsl.settings.{ ClientConnectionSettings, ServerSettings }

Review Comment:
   Can you fix this import so it matches the same style of imports currently in the file



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #622:
URL: https://github.com/apache/pekko-http/pull/622#discussion_r1814676332


##########
http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRenderingSpec.scala:
##########
@@ -13,14 +13,14 @@
 
 package org.apache.pekko.http.impl.engine.http2
 
+import com.typesafe.config.ConfigFactory
 import java.time.format.DateTimeFormatter
 import org.apache.pekko
+import pekko.http.scaladsl.settings.{ ClientConnectionSettings, ServerSettings }
 import pekko.event.NoLogging
 import pekko.http.impl.engine.rendering.DateHeaderRendering
 import pekko.http.scaladsl.model.headers._
-import pekko.http.scaladsl.model.{ ContentTypes, DateTime, HttpHeader, TransferEncodings }
-
-import scala.collection.immutable.Seq
+import pekko.http.scaladsl.model._

Review Comment:
   keep the imports in some order - why are you changing the order of these imports?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "NavidJalali (via GitHub)" <gi...@apache.org>.
NavidJalali commented on code in PR #622:
URL: https://github.com/apache/pekko-http/pull/622#discussion_r1814675882


##########
http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRenderingSpec.scala:
##########
@@ -147,21 +145,39 @@ class HttpMessageRenderingSpec extends AnyWordSpec with Matchers {
       value1.exists(_._1 == "date") shouldBe false
     }
 
+    "handle empty trailer" in {
+      val config = ConfigFactory.load("reference.conf")
+      Try {
+        val rendering = new RequestRendering(ClientConnectionSettings(config), NoLogging)
+        rendering(HttpRequest().withAttributes(Map(AttributeKeys.trailer -> Trailer())))
+      }.isSuccess shouldBe true
+      Try {
+        val rendering = new ResponseRendering(ServerSettings(config), NoLogging, dateHeaderRendering)
+        rendering(
+          HttpResponse().withAttributes(
+            Map(
+              AttributeKeys.trailer -> Trailer(),
+              Http2.streamId -> 0)))
+      }.isSuccess shouldBe true
+    }
+
   }
 
-  private def renderClientHeaders(headers: immutable.Seq[HttpHeader], builder: VectorBuilder[(String, String)],

Review Comment:
   yep sorry



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] Fix partial match [pekko-http]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #622:
URL: https://github.com/apache/pekko-http/pull/622#discussion_r1814656383


##########
http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRenderingSpec.scala:
##########
@@ -147,21 +145,39 @@ class HttpMessageRenderingSpec extends AnyWordSpec with Matchers {
       value1.exists(_._1 == "date") shouldBe false
     }
 
+    "handle empty trailer" in {
+      val config = ConfigFactory.load("reference.conf")
+      Try {
+        val rendering = new RequestRendering(ClientConnectionSettings(config), NoLogging)
+        rendering(HttpRequest().withAttributes(Map(AttributeKeys.trailer -> Trailer())))
+      }.isSuccess shouldBe true
+      Try {
+        val rendering = new ResponseRendering(ServerSettings(config), NoLogging, dateHeaderRendering)
+        rendering(
+          HttpResponse().withAttributes(
+            Map(
+              AttributeKeys.trailer -> Trailer(),
+              Http2.streamId -> 0)))
+      }.isSuccess shouldBe true
+    }
+
   }
 
-  private def renderClientHeaders(headers: immutable.Seq[HttpHeader], builder: VectorBuilder[(String, String)],

Review Comment:
   please revert this change - it is probably here for Scala 2.12 support and there is no reason for this PR to be changing these methods anyway



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org