pjfanning commented on code in PR #744:
URL: https://github.com/apache/pekko-http/pull/744#discussion_r2326623602


##########
http/src/main/resources/reference.conf:
##########
@@ -52,11 +52,20 @@ pekko.http {
 
   # server-sent events
   sse {
-    # The maximum size for parsing server-sent events.
-    max-event-size = 8192
+    # The maximum size for parsing received server-sent events.
+    # This value must be larger than `max-line-size`. Set to 0 to disable 
limit entirely (unlimited).
+    max-event-size = 115713

Review Comment:
   why change the values? - that will affect other users



##########
http-tests/src/test/java/org/apache/pekko/http/javadsl/settings/OversizedSseStrategySimpleTest.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * license agreements; and to You under the Apache License, version 2.0:
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * This file is part of the Apache Pekko project, which was derived from Akka.

Review Comment:
   This is the wrong header for new files - that are not derived from Akka 
files.
   The right header is 
https://github.com/apache/pekko-http/blob/main/project/AddMetaInfLicenseFiles.scala#L1-L16



##########
http-tests/src/test/scala/org/apache/pekko/http/scaladsl/unmarshalling/sse/LineParserSpec.scala:
##########
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * license agreements; and to You under the Apache License, version 2.0:
- *
- *   https://www.apache.org/licenses/LICENSE-2.0
- *
- * This file is part of the Apache Pekko project, which was derived from Akka.
- */
-
-/*
- * Copyright (C) 2009-2022 Lightbend Inc. <https://www.lightbend.com>
- */
-
-package org.apache.pekko.http
-package scaladsl
-package unmarshalling
-package sse
-
-import org.apache.pekko
-import pekko.stream.scaladsl.{ Sink, Source }
-import pekko.util.ByteString
-import org.scalatest.matchers.should.Matchers
-import org.scalatest.wordspec.AsyncWordSpec
-
-final class LineParserSpec extends AsyncWordSpec with Matchers with 
BaseUnmarshallingSpec {

Review Comment:
   why delete this?



##########
docs/src/main/paradox/common/sse-support.md:
##########
@@ -56,6 +56,49 @@ Scala
 Java
 :  @@snip 
[EventStreamMarshallingTest.java](/http-tests/src/test/java/org/apache/pekko/http/javadsl/unmarshalling/sse/EventStreamUnmarshallingTest.java)
 { #event-stream-unmarshalling-example }
 
+## Configuration
+
+Apache Pekko HTTP provides several configuration options for Server-Sent 
Events handling:
+
+### Message Size Limits
+
+The SSE client parser has configurable limits to handle various message sizes:
+
+```hocon
+pekko.http.sse {
+  # The maximum size for parsing received server-sent events.
+  # This value must be larger than `max-line-size`. Set to 0 to disable limit 
entirely (unlimited).
+  max-event-size = 115713
+
+  # The maximum size for parsing received lines of a server-sent event. Set to 
0 to disable limit entirely (unlimited).
+  max-line-size = 115712
+}
+```
+
+### Oversized Message Handling
+
+When SSE messages exceed the configured `max-line-size`, Apache Pekko HTTP 
provides four handling strategies:
+
+- **fail-stream** (default): Fails the stream with a clear error message, 
maintaining backward compatibility
+- **log-and-skip**: Logs a warning and skips the oversized message, continuing 
stream processing
+- **truncate**: Logs a warning and truncates the message to the configured 
limit, continuing processing
+- **dead-letter**: Logs a warning and sends the oversized message to the dead 
letter queue, continuing processing
+
+```hocon
+pekko.http.sse {
+  # How to handle messages that exceed max-line-size limit
+  # Options:
+  #   "fail-stream" - Fail the stream with a clear error message (default)
+  #   "log-and-skip" - Log a warning and skip the oversized message
+  #   "truncate" - Log a warning and truncate the message to max-line-size
+  #   "dead-letter" - Log a warning, send oversized message to dead letters
+  oversized-message-handling = "fail-stream"
+}
+```
+
+For applications that need to handle very large messages (like blockchain data 
or detailed JSON payloads), consider 
+setting `max-line-size = 0` to disable limits entirely, or use one of the 
non-failing handling modes.
+
 Notice that if you are looking for a resilient way to permanently subscribe to 
an event stream,
-Apache Pekko Connectors provides the 
[EventSource](https://pekko.apache.org/docs/pekko-connectors/current/sse.html)
-connector which reconnects automatically with the id of the last seen event.
+Apache Pekko Connectors provides the 
[EventSource](https://pekko.apache.org/docs/pekko-connectors/current/sse.html)connector
 which reconnects automatically with the id of the 

Review Comment:
   can you add back a space or new line before the word 'connector' after the 
link?



##########
http-tests/src/test/java/org/apache/pekko/http/javadsl/settings/OversizedSseStrategySimpleTest.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * license agreements; and to You under the Apache License, version 2.0:
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * This file is part of the Apache Pekko project, which was derived from Akka.

Review Comment:
   can you check all the new files and their source headers?



##########
http/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSentEventSettings.scala:
##########
@@ -42,9 +45,47 @@ abstract class ServerSentEventSettings private[pekko] () { 
self: ServerSentEvent
    */
   def emitEmptyEvents: Boolean
 
-  // ---
+  /**
+   * How to handle messages that exceed max-line-size limit.
+   * Valid options: "fail-stream", "log-and-skip", "truncate", "dead-letter"
+   */

Review Comment:
   new methods in src/main should have `@since 1.3.0` (next non patch release)



-- 
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-unsubscr...@pekko.apache.org

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


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

Reply via email to