* Fixed 500 reported for client disconnection
* Report 499 for ContextCancelled
* Report 499 for ContextCancelled added status text
* Report 499 for ContextCancelled added status text
* 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
* 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
* 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.
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.
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.
* 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.