44 Commits
Author SHA1 Message Date
Fernandez Ludovic a4e2235549 chore: modernize 2025-07-21 22:24:25 +02:00
Fernandez Ludovic f97e824631 chore: update linter 2025-07-15 16:00:27 +02:00
Fernandez Ludovic 6f42deab89 chore: update linter 2025-03-25 03:25:36 +01:00
Fernandez Ludovic d8c7aad654 chore: linting 2025-03-21 16:34:58 +01:00
Fernandez Ludovic 41a4b7d7eb chore: update linter and dependencies 2024-11-08 14:02:37 +01:00
Fernandez Ludovic 01d15583d9 chore: update dependecy, CI, and linter 2024-03-25 13:52:53 +01:00
Fernandez Ludovic 9b3698c553 chore: update Go, CI, and linter 2024-01-24 23:09:05 +01:00
Fernandez Ludovic c6ffeddb6b chore: update Go, CI, and linter 2023-09-27 08:55:48 +02:00
Fernandez Ludovic ef33067ef0 chore: update dependecy, CI, and linter 2023-02-21 16:06:22 +01:00
Fernandez Ludovic 6df7a99088 feat: follow slog interface 2022-11-19 13:26:41 +01:00
Fernandez Ludovic 736173ce4c feat: rewrite options and logger 2022-11-11 00:31:09 +01:00
Fernandez Ludovic 2bd95e442a feat: cleaning the deprecated elements 2022-11-07 10:24:03 +01:00
Fernandez Ludovic d43b3ad9b9 chore: linting 2022-05-07 13:17:39 +02:00
Fernandez Ludovic aa4dc2e9a0 fix: UserInfo copy in CopyUrl 2022-05-07 12:06:22 +02:00
Fernandez Ludovic e5c657ef5f fix: apply linting 2022-05-05 00:28:29 +02:00
Jakub CoufalandEmile Vauge c4d4cc1a84 Fixed 500 reported for client disconnection (#155)
* Fixed 500 reported for client disconnection

* Report 499 for ContextCancelled

* Report 499 for ContextCancelled added status text

* Report 499 for ContextCancelled added status text
2018-08-16 16:55:37 +02:00
Ludovic FernandezandEmile Vauge 510e0d1bfc refactor: migrate from go-check to Testify. (#146) 2018-07-09 16:30:28 +02:00
Ludovic FernandezandArchis f905dbdc10 Linting (#144)
* refactor: minor code changes.

* fix: checks-fmt.

* refactor: comments.
2018-07-07 06:23:06 -07:00
Andreas LinzandArchis 1bff799876 Implement context logger for remaining packages (#94)
* Fix doc comment for Stream option setter

This was left from long ago.

* Allow setting the logger the forwarder uses

* Document the Logger option

* Use logrus.StandardLogger() as the default

This means the behaviour will be the same as before, e.g. global
logrus settings will be set on the forward logger by default.

* Implement context-logger for buffer package

* Fix a typo

compete → complete

* Implement context-logger for circuit breaker package

There is one single place where the context-logger is not implemented
and this is cbreaker/predicates.go:53 because it had required to change
the API.

* Implement context-logger for connection limiter package

* Implement context-logger for rate limiter package

* Implement context-logger for round-robin package

* Implement context-logger for stream package

* Implement context-logger for trace package

* Rename opt-setter to fix redeclaration

* Use context logger's level

* Modify context-logger properties directly

This is required because the setter's are not part of the Logger
interface.

* Set standard logger for {Default,Error}Handler

* Use logger from CircuitBreaker

* Remove leftover import

* Fix some copy-paste errors

* Remove redundant logger setup

* Remove unused logger

* Implement context-logger for ProxyWriter

A pair of constructors was added so a default logger is set.
Instantiating the ProxyWriter struct without setting a logger would have
caused a nil pointer exception.

* Fix missing usages of context-logger

Ripgrep to the rescue:

$ rg --sort-files --regexp '\s+log\.'

* Fix build breaks with context logger

* Match log levels of newer commits
2018-07-07 01:31:53 -07:00
SALLEYRON JulienandEmile Vauge ce6a7cff59 Add logs when error is generated in error handler (#142) 2018-07-06 10:10:11 +02:00
MichaelandEmile Vauge 5f37b03bbb fix: remove close notify support (#140) 2018-06-18 18:08:39 +02:00
SALLEYRON JulienandEmile Vauge 6f5c5ccc84 Fix http-pipelining (#130) 2018-04-09 17:15:39 +02:00
Ludovic FernandezandEmile Vauge 1fe46d1aeb Enhance code quality analysis (#104)
* chore: add new Make targets.

* refactor: code review.

* chore(travis): go import path.
2017-12-18 10:25:18 +01:00
arthur 09873248fd fix logrus path 2017-07-10 18:06:33 +08:00
Paul Querna 5f86a76a50 Improve CopyHeaders performance to use a direct slice append rather than .Add() 2017-04-28 09:11:53 -07:00
Paul Querna bfff166c86 Add benchmark of CopyHeaders 2017-04-28 09:08:24 -07:00
ArchisandGitHub 10e6c1ab57 Logging revamp (#64) (#67)
* Logging revamp (#64)

* Logging revamp

This change revamps logging in the following ways:
1. In the buffer (and any place really) where an error is returned,
   the log type is "Error" consistently, rather than info.

2. In ALL middlewares is a debug-level log that is emitted when a
   request is beginning to be served, and once when the ServeHTTP
   method exits (using defer). This allows, under debug conditions,
   a way to trace the flow of a request.

3. Finally, an important log entry which I feel was always missing,
   was an info-level entry that mentioned which specific backend
   server a particular request hit.

More logging improvements

More logging improvements

Http Streaming forwarder wasn't using ProxyWriter at all.

This was a fix made by Roy Sundahl. I'm merging it in here.

Attach standard logger as error logger for reverse proxy.

Revert "Attach standard logger as error logger for reverse proxy."

This reverts commit a39e0e7a1c9ecbd13af945a684a81fcaaa5a51f2.

Added an HTTP Request serializer for logging

Updated Serializer for http.Request objects

The challenge with logrus is it uses json.Marshall to serialize
object fields, but will log nothing if there's a marshalling error.

This prevented http.Request from getting serialized, and thus prevented
the entire entry from being logged.

By using httputil.DumpRequest, this change serializes
all http.Request objects (even if there's an error), and makes
sure a log entry is pushed.

Use JSON Serializer so the request is machine-parsable.

Revert "Use JSON Serializer so the request is machine-parsable."

This reverts commit a99a99299f2300dcaab1bb479c3f53cc1d76cc50.

Request serializer was a bad idea.

Attempting to serialize requests was a bad idea.

Serialize Http Request

Go fmt

* Fixed UT

Due to different golang versions, the fields in the struct
http.Request might be different across different runs of
the Unit Test. That means verifying that an http.Request correctly
serializes to a JSON String is not a fixed predictable operation
that is also portable across golang versions.

This change modifies the test to simply ensure length of the
generated string is more than zero.

Gated all expensive logs behind their log level.

This will ensure that if the log level is
what the log entry is, expensive processing
of serializing a full HTTP request isn't performed
per log entry.

* Added a benchmark test
2017-04-21 11:50:41 -05:00
ArchisandGitHub bac7799115 Revert "Logging revamp (#64)" (#66)
This reverts commit f3e1c9ca8e.
2017-04-20 19:58:53 -05:00
ArchisandGitHub f3e1c9ca8e Logging revamp (#64)
* Logging revamp

This change revamps logging in the following ways:
1. In the buffer (and any place really) where an error is returned,
   the log type is "Error" consistently, rather than info.

2. In ALL middlewares is a debug-level log that is emitted when a
   request is beginning to be served, and once when the ServeHTTP
   method exits (using defer). This allows, under debug conditions,
   a way to trace the flow of a request.

3. Finally, an important log entry which I feel was always missing,
   was an info-level entry that mentioned which specific backend
   server a particular request hit.

More logging improvements

More logging improvements

Http Streaming forwarder wasn't using ProxyWriter at all.

This was a fix made by Roy Sundahl. I'm merging it in here.

Attach standard logger as error logger for reverse proxy.

Revert "Attach standard logger as error logger for reverse proxy."

This reverts commit a39e0e7a1c9ecbd13af945a684a81fcaaa5a51f2.

Added an HTTP Request serializer for logging

Updated Serializer for http.Request objects

The challenge with logrus is it uses json.Marshall to serialize
object fields, but will log nothing if there's a marshalling error.

This prevented http.Request from getting serialized, and thus prevented
the entire entry from being logged.

By using httputil.DumpRequest, this change serializes
all http.Request objects (even if there's an error), and makes
sure a log entry is pushed.

Use JSON Serializer so the request is machine-parsable.

Revert "Use JSON Serializer so the request is machine-parsable."

This reverts commit a99a99299f2300dcaab1bb479c3f53cc1d76cc50.

Request serializer was a bad idea.

Attempting to serialize requests was a bad idea.

Serialize Http Request

Go fmt

* Fixed UT

Due to different golang versions, the fields in the struct
http.Request might be different across different runs of
the Unit Test. That means verifying that an http.Request correctly
serializes to a JSON String is not a fixed predictable operation
that is also portable across golang versions.

This change modifies the test to simply ensure length of the
generated string is more than zero.
2017-04-15 09:03:37 -07:00
ArchisandGitHub 7af6d7f3c3 Added the ability to hijack connections (for Websockets) (#59)
During my web socket tests I realized that ProxyWriter
and BufferWriter didn't implement the http.Hijacker
interface.

Moreover, there wasn't sufficient debugging info in the logs
that told us which implementation of ResponseWriter was being used.

This information is necessary in the future when proxies
are injected and we need to quickly figure out where the gaps are.

I've added logs which emit the type of the implementer of an interface,
whenever it cannot be cast into a target interface.

I also implemented http.Hijacker on ProxyWriter and BufferWriter.
2017-01-17 14:43:01 -08:00
ArchisandGitHub 4e4fad5610 Implement http.CloseNotifier in the ResponseWriter implementations (#54)
Ever since I implemented chunked encoding/streaming,
the possibility of long-polling also brings with it
the risk that a client connection may have been closed
during the poll.

Fortunately, go's http.Server has the ability to close
the reverse-proxied connections (technically cancel the
http.Handler it calls out to.)

For this to happen, we have to pass-through the
http.CloseNotifier interface downstream to the listener.

That is what this change does. This is no different
from how the http.Flusher is implemented
in both the BufferWriter and ProxyWriter.
2016-10-26 07:28:19 -07:00
ArchisandGitHub e7b38e42b9 Rename "Stream" to "Buffer", and make "Stream" a pass-through for now (#45)
* Renamed Stream to Buffer

This handles the issue: https://github.com/vulcand/oxy/issues/9

It is a better name and helps clarify what the intent and function of this
object is.

* Forked the original stream into Buffer.

* Fixed a build break

* Simplified stream to be pass-through for now.

* Most UTs for stream expect StatusOk as return code

* More updates towards allowing streaming

1. Initial run at the feedback received on the code review, namely,
   updated all comments/docs to say "buffer" in the buffer part of the
   code, and fixed the mistaken package "steam" to "stream"

2. In fwd.go, replaced RoundTripper with ReverseProxy when
   the stream flag is provided. Not sure yet ReverseProxy
   won't buffer and wait for EOF to flush bytes down to the client
   but having a httpStreamingForwarded as a playground, ensures
   the working version of the forwarded isn't affected by any bugs/mistakes
   I introduce.

* Finished up the httpStreamingForwarder.

* Externalize FlushInterval, with a default, and add a URL connect/disconnect listener.

* Make URL to listener, a pointer so listeners can track them correctly.

* Go fmt

* Updated documentation for stream

* Rename Stream test correctly.

* Rebased against master

* Merge artifact removed

* Added a chunked transfer encoding unit test.
2016-08-30 11:35:57 -07:00
ArchisandGitHub 34e2ebf3d7 Drop internal log lib, use logrus (#50)
* Drop internal log lib, use logrus

* Removed merge artifacts

* Bad merge

* More missing ctx.log references
2016-08-30 08:24:20 -07:00
Xavier Milliard 763a5e8430 Fix test 2015-02-10 14:23:13 +01:00
Alexander Klizhentas 18e951f6d0 Fix 2015-01-12 16:09:09 -08:00
Alexander Klizhentas 34a14e581b Implement structured tracer 2015-01-12 15:57:44 -08:00
Alexander Klizhentas 2798bec445 Bugfixes in rebalancing and error handling with tests 2014-12-24 13:09:53 -08:00
Alexander Klizhentas 2777ef9456 Cleanup logging 2014-12-21 11:59:47 -08:00
Alexander Klizhentas 58ad9d5a33 Add parsing basic auth 2014-12-16 11:21:21 -08:00
Alexander Klizhentas 6d9077a9f4 Update interfaces a little bit 2014-12-12 22:54:43 -08:00
Alexander Klizhentas f99d039025 Stream package covered by tests 2014-12-11 10:49:42 -08:00
Alexander Klizhentas 181489c25f Add more tests 2014-12-10 22:32:27 -08:00
Alexander Klizhentas 1daee77194 More tests 2014-12-10 17:47:25 -08:00
Alexander Klizhentas 1567438717 More tests for forwarder.
couple of things remained to test for forwarder - check that url is not touched
2014-12-10 10:20:42 -08:00