@@ -452,13 +452,19 @@ public interface Context extends Registry {
452452 /**
453453 * Recreates full/entire request url using the <code>Host</code> header.
454454 *
455+ * If you run behind a reverse proxy that has been configured to send the X-Forwarded-* header,
456+ * please consider to add {@link ProxyPeerAddressHandler} to your pipeline.
457+ *
455458 * @return Full/entire request url using the <code>Host</code> header.
456459 */
457460 @ Nonnull String getRequestURL ();
458461
459462 /**
460463 * Recreates full/entire request url using the <code>Host</code> header.
461464 *
465+ * If you run behind a reverse proxy that has been configured to send the X-Forwarded-* header,
466+ * please consider to add {@link ProxyPeerAddressHandler} to your pipeline.
467+ *
462468 * @param path Path to use.
463469 * @return Full/entire request url using the <code>Host</code> header.
464470 */
@@ -471,7 +477,9 @@ public interface Context extends Registry {
471477 * @param useProxy True to trust/use the <code>X-Forwarded-Host</code>.
472478 * @return Full/entire request url using the <code>X-Forwarded-Host</code> when present
473479 * or fallback to <code>Host</code> header when missing.
480+ * @deprecated Use {@link ProxyPeerAddressHandler}.
474481 */
482+ @ Deprecated
475483 @ Nonnull String getRequestURL (boolean useProxy );
476484
477485 /**
@@ -482,44 +490,95 @@ public interface Context extends Registry {
482490 * @param useProxy True to trust/use the <code>X-Forwarded-Host</code>.
483491 * @return Full/entire request url using the <code>X-Forwarded-Host</code> when present
484492 * or fallback to <code>Host</code> header when missing.
493+ * @deprecated Use {@link ProxyPeerAddressHandler}.
485494 */
495+ @ Deprecated
486496 @ Nonnull String getRequestURL (@ Nonnull String path , boolean useProxy );
487497
488498 /**
489499 * The IP address of the client or last proxy that sent the request.
490500 *
501+ * If you run behind a reverse proxy that has been configured to send the X-Forwarded-* header,
502+ * please consider to add {@link ProxyPeerAddressHandler} to your pipeline.
503+ *
491504 * @return The IP address of the client or last proxy that sent the request.
492505 */
493506 @ Nonnull String getRemoteAddress ();
494507
508+ /**
509+ * Set IP address of client or last proxy that sent the request.
510+ *
511+ * @param remoteAddress Remote Address.
512+ * @return This context.
513+ */
514+ @ Nonnull Context setRemoteAddress (@ Nonnull String remoteAddress );
515+
495516 /**
496517 * Return the host that this request was sent to, in general this will be the
497- * value of the Host header, minus the port specifier.
518+ * value of the Host header, minus the port specifier. Unless, it is set manually using the
519+ * {@link #setHost(String)} method.
520+ *
521+ * If you run behind a reverse proxy that has been configured to send the X-Forwarded-* header,
522+ * please consider to add {@link ProxyPeerAddressHandler} to your pipeline.
498523 *
499524 * @return Return the host that this request was sent to, in general this will be the
500525 * value of the Host header, minus the port specifier.
501526 */
502527 @ Nonnull String getHost ();
503528
529+ /**
530+ * Set the host (without the port value).
531+ *
532+ * Please keep in mind this method doesn't alter/modify the <code>host</code> header.
533+ *
534+ * @param host Host value.
535+ * @return This context.
536+ */
537+ @ Nonnull Context setHost (@ Nonnull String host );
538+
539+ /**
540+ * Return the host and port that this request was sent to, in general this will be the
541+ * value of the Host.
542+ *
543+ * If you run behind a reverse proxy that has been configured to send the X-Forwarded-* header,
544+ * please consider to add {@link ProxyPeerAddressHandler} to your pipeline.
545+ *
546+ * @return Return the host that this request was sent to, in general this will be the
547+ * value of the Host header.
548+ */
549+ @ Nonnull String getHostAndPort ();
550+
504551 /**
505552 * Return the host and port that this request was sent to, in general this will be the
506553 * value of the Host or X-Forwarded-Host header.
507554 *
508555 * @param useProxy When true this method looks for host data in the X-Forwarded-Host header.
509556 * @return Return the host that this request was sent to, in general this will be the
510557 * value of the Host header.
558+ * @deprecated Use {@link ProxyPeerAddressHandler}.
511559 */
512- @ Nullable String getHostAndPort (boolean useProxy );
560+ @ Deprecated
561+ @ Nonnull String getHostAndPort (boolean useProxy );
513562
514563 /**
515564 * Return the port that this request was sent to. In general this will be the value of the Host
516565 * header, minus the host name.
517566 *
518- * @return Return the port that this request was sent to. In general this will be the value of the Host
519- * header, minus the host name.
567+ * If no host header is present, this method returns the value of {@link #getServerPort()}.
568+ *
569+ * @return Return the port that this request was sent to. In general this will be the value of
570+ * the Host header, minus the host name.
520571 */
521572 int getPort ();
522573
574+ /**
575+ * Set port this request was sent to.
576+ *
577+ * @param port Port.
578+ * @return This context.
579+ */
580+ @ Nonnull Context setPort (int port );
581+
523582 /**
524583 * The name of the protocol the request. Always in lower-case.
525584 *
@@ -557,6 +616,14 @@ public interface Context extends Registry {
557616 */
558617 @ Nonnull String getScheme ();
559618
619+ /**
620+ * Set HTTP scheme in lower case.
621+ *
622+ * @param scheme HTTP scheme in lower case.
623+ * @return This context.
624+ */
625+ @ Nonnull Context setScheme (@ Nonnull String scheme );
626+
560627 /* **********************************************************************************************
561628 * Form API
562629 * **********************************************************************************************
0 commit comments