aboutsummaryrefslogtreecommitdiffstats
path: root/modules/httplib
Commit message (Collapse)AuthorAgeFilesLines
* Fix wrong last modify time (#32102)Lunny Xiao2024-09-211-0/+1
|
* Only use Host header from reverse proxy (#32060)wxiaoguang2024-09-202-12/+6
| | | | | | | | | X-Forwarded-Host has many problems: non-standard, not well-defined (X-Forwarded-Port or not), conflicts with Host header, it already caused problems like #31907. So do not use X-Forwarded-Host, just use Host header directly. Official document also only uses `Host` header and never mentioned others.
* Fix duplicate sub-path for avatars (#31365)wxiaoguang2024-06-152-13/+25
| | | | | | | | | | | Fix #31361, and add tests And this PR introduces an undocumented & debug-purpose-only config option: `USE_SUB_URL_PATH`. It does nothing for end users, it only helps the development of sub-path related problems. And also fix #31366 Co-authored-by: @ExplodingDragon
* Improve reverse proxy documents and clarify the AppURL guessing behavior ↵wxiaoguang2024-05-192-17/+26
| | | | | | | | | | | | (#31003) Fix #31002 1. Mention Make sure `Host` and `X-Fowarded-Proto` headers are correctly passed to Gitea 2. Clarify the basic requirements and move the "general configuration" to the top 3. Add a comment for the "container registry" 4. Use 1.21 behavior if the reverse proxy is not correctly configured Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Refactor AppURL usage (#30885)wxiaoguang2024-05-072-8/+111
| | | | | | | | Fix #30883 Fix #29591 --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Skip gzip for some well-known compressed file types (#30796)wxiaoguang2024-05-021-0/+8
| | | Co-authored-by: silverwind <me@silverwind.io>
* Refactor external URL detection (#29973)wxiaoguang2024-03-222-3/+10
| | | | Follow #29960, `IsExternalURL` is not needed anymore. Add some tests for `RedirectToCurrentSite`
* Refactor URL detection (#29960)wxiaoguang2024-03-212-29/+82
| | | "Redirect" functions should only redirect if the target is for current Gitea site.
* Less naked returns (#25713)65432023-07-072-4/+6
| | | | | just a step towards #25655 and some related refactoring
* Replace `interface{}` with `any` (#25686)silverwind2023-07-041-1/+1
| | | | | Result of running `perl -p -i -e 's#interface\{\}#any#g' **/*` and `make fmt`. Basically the same [as golang did](https://github.com/golang/go/commit/2580d0e08d5e9f979b943758d3c49877fb2324cb).
* Use fetch to send requests to create issues/comments (#25258)wxiaoguang2023-06-162-0/+65
| | | | | | | | | | | | | | | | Follow #23290 Network error won't make content lost. And this is a much better approach than "loading-button". The UI is not perfect and there are still some TODOs, they can be done in following PRs, not a must in this PR's scope. <details> ![image](https://github.com/go-gitea/gitea/assets/2114189/c94ba958-aa46-4747-8ddf-6584deeed25c) </details>
* Use standard HTTP library to serve files (#24693)wxiaoguang2023-05-132-41/+7
| | | | | | | `http.ServeFile/ServeContent` handles `If-xxx`, `Content-Length`, `Range` and `Etag` correctly After this PR, storage files (eg: avatar) could be responded with correct Content-Length.
* Make repository response support HTTP range request (#24592)wxiaoguang2023-05-094-0/+369
| | | | | | Replace #20480 Replace #18448 Close #16414
* Refactor internal API for git commands, use meaningful messages instead of ↵wxiaoguang2023-03-291-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "Internal Server Error" (#23687) # Why this PR comes At first, I'd like to help users like #23636 (there are a lot) The unclear "Internal Server Error" is quite anonying, scare users, frustrate contributors, nobody knows what happens. So, it's always good to provide meaningful messages to end users (of course, do not leak sensitive information). When I started working on the "response message to end users", I found that the related code has a lot of technical debt. A lot of copy&paste code, unclear fields and usages. So I think it's good to make everything clear. # Tech Backgrounds Gitea has many sub-commands, some are used by admins, some are used by SSH servers or Git Hooks. Many sub-commands use "internal API" to communicate with Gitea web server. Before, Gitea server always use `StatusCode + Json "err" field` to return messages. * The CLI sub-commands: they expect to show all error related messages to site admin * The Serv/Hook sub-commands (for git clients): they could only show safe messages to end users, the error log could only be recorded by "SSHLog" to Gitea web server. In the old design, it assumes that: * If the StatusCode is 500 (in some functions), then the "err" field is error log, shouldn't be exposed to git client. * If the StatusCode is 40x, then the "err" field could be exposed. And some functions always read the "err" no matter what the StatusCode is. The old code is not strict, and it's difficult to distinguish the messages clearly and then output them correctly. # This PR To help to remove duplicate code and make everything clear, this PR introduces `ResponseExtra` and `requestJSONResp`. * `ResponseExtra` is a struct which contains "extra" information of a internal API response, including StatusCode, UserMsg, Error * `requestJSONResp` is a generic function which can be used for all cases to help to simplify the calls. * Remove all `map["err"]`, always use `private.Response{Err}` to construct error messages. * User messages and error messages are separated clearly, the `fail` and `handleCliResponseExtra` will output correct messages. * Replace all `Internal Server Error` messages with meaningful (still safe) messages. This PR saves more than 300 lines, while makes the git client messages more clear. Many gitea-serv/git-hook related essential functions are covered by tests. --------- Co-authored-by: delvh <dev.lh@web.de>
* Implement FSFE REUSE for golang files (#21840)flynnnnnnnnnn2022-11-271-2/+1
| | | | | | | | | Change all license headers to comply with REUSE specification. Fix #16132 Co-authored-by: flynnnnnnnnnn <flynnnnnnnnnn@github> Co-authored-by: John Olheiser <john.olheiser@gmail.com>
* refactor httplib (#18338)Gusted2022-01-191-285/+7
| | | | | | - Remove a lot of unused code(most if not all were introduced in gogs for webhooks usages). Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* refactor: move from io/ioutil to io and os package (#17109)Eng Zer Jun2021-09-221-5/+4
| | | | | | | | | The io/ioutil package has been deprecated as of Go 1.16, see https://golang.org/doc/go1.16#ioutil. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Add an abstract json layout to make it's easier to change json library (#16528)Lunny Xiao2021-07-241-2/+1
| | | | | | | | | | | * Add an abstract json layout to make it's easier to change json library * Fix import * Fix import sequence * Fix blank lines * Fix blank lines
* Second attempt at preventing zombies (#16326)zeripath2021-07-141-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Second attempt at preventing zombies * Ensure that the pipes are closed in ssh.go * Ensure that a cancellable context is passed up in cmd/* http requests * Make cmd.fail return properly so defers are obeyed * Ensure that something is sent to stdout in case of blocks here Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint 2 Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint 3 Signed-off-by: Andrew Thornton <art27@cantab.net> * fixup Signed-off-by: Andrew Thornton <art27@cantab.net> * Apply suggestions from code review Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lauris BH <lauris@nix.lv>
* fix webhook timeout bug (#15613)Lunny Xiao2021-04-251-4/+5
| | | * Also fix the potential problem in httplib
* Migrate to use jsoniter instead of encoding/json (#14841)zeripath2021-03-011-1/+3
| | | | | | | | | | * Migrate to use jsoniter * fix tests * update gitea.com/go-chi/binding Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
* Add golangci (#6418)kolaente2019-06-121-18/+17
|
* Add sensitive headers (#3429)Antoine GIRARD2018-01-311-0/+6
| | | | | | | * Add HeaderWithSensitiveCase methods to respect casing * Update webhook.go
* Use GiteaServer as the user agent for http requests (#3404)Sandro Santilli2018-01-221-1/+1
| | | Otherwise we're still presenting ourselves as GogsServer...
* Add internal routes for ssh hook comands (#1471)Lunny Xiao2017-04-191-0/+5
| | | | | | | | | | | | | | | | * add internal routes for ssh hook comands * fix lint * add comment on why package named private not internal but the route name is internal * add comment above package private why package named private not internal but the route name is internal * remove exp time on internal access * move routes from /internal to /api/internal * add comment and defer on UpdatePublicKeyUpdated
* Fix typos in models/ and modules/ (#1248)Ethan Koenig2017-03-151-1/+1
|
* add ProxyFromEnvironment if none set (#1096)Schwobaland2017-03-021-1/+5
|
* Golint fixed for modules/httplibLunny Xiao2016-11-251-15/+18
|
* Remove unused testsUnknwon2016-02-131-206/+0
| | | | | Module httplib will be replaced a well done third-party package soon, so remove its unused tests
* fix insecure tls when trigger taskUnknwon2015-10-261-6/+6
|
* add webhook recent deliveriesUnknwon2015-08-271-122/+123
|
* #634Unknwon2014-11-182-45/+57
|
* Fix #362, update code with upstreamUnknwon2014-08-232-86/+366
|
* Finish new web hook pagesUnknwon2014-08-091-62/+0
|
* Fix #98, support web hookUnknown2014-05-063-0/+424