Commit Graph

1448 Commits

Author SHA1 Message Date
Erik Dubbelboer f0b0cfe9b2 Don't log ErrBadTrailer by default 2022-02-23 17:12:07 +01:00
Pavel Burak 6937fee923 fix: (useless check), skip Response body if http method HEAD (#1224) 2022-02-20 18:14:24 +01:00
Aoang b85d2a274b Fix http proxy behavior (#1221)
Add Host header fix behavior
https://datatracker.ietf.org/doc/html/rfc7230#section-5.4
2022-02-18 10:52:19 +01:00
Jack.Ju ad8a07a86e RequestHeader support set no default ContentType (#1218) 2022-02-16 15:52:18 +01:00
lin longhjui c94581c005 support configure HostClient (#1214)
Co-authored-by: linlonghui <linlonghui@chandashi.com>
2022-02-15 08:03:54 +01:00
Sergey Ponomarev 632e222c2a Client examples (#1208)
* examples/host_client

* examples/client

* examples/client/client.go refine imports

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

* examples/host_client/hostclient.go refine imports

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2022-02-09 11:09:36 +01:00
Sergey Ponomarev 6a3cc2325b uri_test.go use example.com for clearness (#1212)
* uri_test.go replace xxx.com with example.com

* uri_test.go replace foobar.com with example.com

* uri_test.go use example.com inside of testURIUpdate()

* uri_test.go use example.com instead of google.com

* uri_test.go use example.com instead of google.com

* uri_test.go testURIUpdate() host with port
2022-02-09 10:19:34 +01:00
Mikhail Faraponov 9d665e00df Update dependencies (#1204)
Co-authored-by: Mikhail Faraponov <mikefaraponov@Mikhails-MacBook-Pro.local>
2022-02-01 13:09:04 +01:00
ArminBTVS 8d7953eda7 Fix scheme check for not yet parsed requests (#1203)
* Fix scheme check for not yet parsed requests

At this point the request might not be parsed yet and set. In that case uri is empty and isHttps() returns always false. I don't expect this is intended?

Otherwise URL() must be called before actually passing the request to client.Do()

* Add test

* Please linter
2022-01-31 22:02:58 +08:00
tyltr 61aa8b17a2 remove redundant code (#1202) v1.33.0 2022-01-27 03:17:00 +01:00
Sergio VS 436977654a fix(hijack): reuse RequestCtx (#1201)
* fix(hijack): reuse RequestCtx

* fix(test/hijack): increase wait time

* fix(test/hijack): wait for all connections to finish to check responses
2022-01-22 04:54:37 +01:00
Sergio VS 2aca3e8263 fix(hijack): reset userValues after hijack handler execution (#1199)
* fix(hijack): reset userValues after hijack handler execution

* feat: add test

* fix: typo

* fix(test): race condition
2022-01-18 12:45:41 +01:00
Mikhail Faraponov 9123060b3a Updated dependencies (#1194)
Co-authored-by: Mikhail Faraponov <mikefaraponov@Mikhails-MacBook-Pro.local>
2022-01-14 05:01:51 +01:00
Erik Dubbelboer 7eeb00e1cc Make tests less flaky (#1189) v1.32.0 2022-01-10 05:15:30 +01:00
Mikhail Faraponov d19b8727b0 Update tcpdialer.go (#1188) 2022-01-09 16:03:22 +01:00
Tolyar c727b9981b Release UseHostHeader in ReleaseRequest() (#1185)
* Fix UseHostHeader for DoTimeout + tests

* Release UseHostHeader in ReleaseRequest() + tests
2021-12-28 19:26:04 +08:00
Tolyar 6c0518b89a Fix UseHostHeader for DoTimeout + tests (#1184) 2021-12-26 21:08:23 +08:00
Kilos Liu 6b55811130 Add MaxIdleWorkerDuration to Server. (#1183) 2021-12-26 07:56:34 +01:00
Tolyar 4517204499 Allow to set Host header for Client (#1169)
* Allow to set Host header for Client

* Allow to change Host header without tests violation

* Rename AllowToChangeHostHeader and add tests.

* Allow to use empty uri.Host() when req.Header.Host() does not empty
2021-12-17 06:26:17 +01:00
Sergio VS 258a4c17b4 fix: reset response after reset user values on keep-alive connections (#1176) 2021-12-16 05:27:02 +01:00
Erik Dubbelboer e9db537178 Use %w to wrap errors (#1175) 2021-12-13 09:41:34 +01:00
Erik Dubbelboer 7db0597e75 Fix bad request trailer panic 2021-12-13 09:01:16 +01:00
Erik Dubbelboer 4aadf9a85e Fix parseTrailer panic 2021-12-06 14:48:36 +01:00
ichx da7ff7a208 Add trailer support (#1165)
* Add trailer support

* fix issue and add documentation

* remove redundant code

* add error return for add/set trailer method

* fix lint error

* fix bad trailer error return issue and update bad content-length error

* update errNonNumericChars

* update errNonNumericChars

* fix issue about error and fix typo
2021-12-05 14:11:51 +01:00
Sergio VS 017f0aa09d fix: reset request after reset user values on keep-alive connections (#1162)
* fix: reset request after reset user values on keep-alive connections

* test: add test for reset request after reset user values
2021-11-23 11:12:06 +01:00
ichx 3b117f8f1e feat: close idle connections when server shutdown (#1155)
* feat: close idle connections when server shutdown

* Fix redundant code

* Update test

* Update test
2021-11-13 11:53:10 +01:00
ichx a94a2c3253 Remove redundant code (#1154) 2021-11-11 19:40:30 +01:00
Erik Dubbelboer f7c354c760 Fix race condition in Client.mCleaner
This could result in HostClients being removed that were still in use.
2021-11-11 16:59:56 +01:00
ichx c078a9d550 Add string and bytes buffer convert trick in README (#1151)
* Add string and bytes buffer convert trick in README

* Update README.md
2021-11-10 22:14:55 +01:00
Sergey Ponomarev 3ff6aaa591 uri: isHttps() and isHttp() (#1150)
* uri: isHttps() and isHttp()

Use them instead of manual schema comparison

* uri: use SetSchemeBytes()
2021-11-08 13:35:26 +01:00
Sergey Ponomarev 8febad0797 http.go: Request.SetURI() (Fix #1141) (#1148)
Currently, the only way to set URI for a request is to call SetRequestURI(string).
Then when a request performed the string will be parsed into a fasthttp.URI struct.
If there are many requests with the same URI then we'll waste CPU for a parsing of the same URI string.
With the new SetURI(*URI) method we can once parse a URI string into a fasthttp.URI struct and then reuse it for many requests.
Unfortunately the URI will be copied because may be modified inside the request.
But anyway this will be more lightweight than parsing.
2021-11-08 13:09:35 +01:00
Shivansh Vij 2ca01c7efb fix: Status Line parsing and writing (#1135)
* Adding zero-allocation uint64 to byte slice conversion and fixing the ResponseHeader.SetStatusLine function call signature

* Removing unnecessary i2b function

* Fixing various bugs

* Adding test cases

* Commenting AppendStatusLine

* Update status.go

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

* Update header.go

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

* Cleaning up references to strHTTP11, using formatStatusLine for invalidStatusLine, and making `appendStatusLine` an unexported function

Issue: https://github.com/valyala/fasthttp/issues/1132

* Fixing merge conflicts

Issue: https://github.com/valyala/fasthttp/issues/1132

* Replacing []byte{} with nil in some test cases

Issue: https://github.com/valyala/fasthttp/issues/1132

* Cleaning up parsing first line, and improving StatusMessage function

Issue: https://github.com/valyala/fasthttp/issues/1132

* Fixing as per PR

* Update header.go

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

* Update header.go

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

* Fixing as per requested changes

* Update header_test.go

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2021-11-08 09:44:02 +01:00
Erik Dubbelboer 931d0a4523 Fix lint 2021-11-04 13:24:40 +01:00
halst d613502912 use sync.map is better (#1145)
* use sync.map is better

* Use LoadOrStore
2021-11-04 13:01:58 +01:00
Erik Dubbelboer c15e642a16 Don't run all race tests on windows (#1143)
* Don't run all race tests on windows

It's too slow and gives a lot of false positives in our tests.

* No FS tests on windows
2021-10-31 22:09:40 +01:00
tyltr 6006c8761d chore (#1137) 2021-10-30 15:58:20 +02:00
Erik Dubbelboer 6d4db9bb7e Fix race condition in getTCPAddrs 2021-10-29 20:24:17 +02:00
Shivansh Vij 528dd62239 feat: ability to read body separate from header (#1130)
* Adding ConvertHTTPRequest and renaming ConvertRequest to ConvertFastRequest

* Removing forServer boolean from ConvertHTTPRequest

* Preparing for PR

* Reverting adaptor changes

* Fixing godoc, adding req.ReadBody function as well

* Update comment to be more clear

As per @erikdubbelboer suggestion

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2021-10-22 21:00:40 +02:00
Valentin Paz Marcolla 556aa814e4 feat: ability to edit status messages (#1126)
* SetStatusMessage

* Docstring

* statusLine in header

* Use statusLine as []byte + ResponseHeader parsing

* status line getter
2021-10-22 17:53:35 +02:00
Sergio VS 4cfec1a795 feat: make public Server.TLSConfig (#1128)
* feat: make public Server.TLSConfig

* fix: clone tls config only when ServeTLS, ServeTLSEmbed, ListenAndServeTLS or ListenAndServeTLSEmbed
2021-10-20 20:41:02 +02:00
tyltr fe7d90ed50 remove redundant code (#1127) 2021-10-19 12:47:55 +02:00
Erik Dubbelboer 81fc968270 Add warning to readme v1.31.0 2021-10-09 20:39:05 +02:00
tyltr 7fdd5261e8 feat: a new userData API Remove (#1117)
* feat:userData new api "delete"

* ctx api `remove`

* rename

* modify
2021-10-08 17:45:45 +02:00
tyltr f307299246 feat:no need to store nil (#1116)
* feat:no  need  to  store nil

* lint
2021-10-06 18:03:16 +02:00
Erik Dubbelboer ad6d128614 URI.Parse should never change it's input
Decode the URI in place, but use the bytes of the URI instead of the
bytes of the input parameter.
2021-10-03 10:30:20 +02:00
Erik Dubbelboer ffab77a59d Improve return value reusability documentation 2021-10-01 13:38:31 +02:00
Erik Dubbelboer 542a203b42 Properly parse URI
Use URI parse code based on net/uri to validate hostnames.
2021-10-01 13:38:31 +02:00
tyltr 711e421685 feat: improve TCPDialer by sync.map instead of map+mutex (#1106) 2021-09-20 16:44:32 +02:00
Oleg Kovalov adc0e57d0d Remove useless runtime.KeepAlive (#1107)
* Remove useless runtime.KeepAlive

* Update bytesconv.go
2021-09-20 16:33:03 +02:00
tyltr 44d0333ba3 fix: typo (#1105) 2021-09-17 09:16:52 +02:00