summaryrefslogtreecommitdiffstats
path: root/routers/repo/download.go
Commit message (Collapse)AuthorAgeFilesLines
* Refactor routers directory (#15800)Lunny Xiao2021-06-091-219/+0
| | | | | | | | | | | * refactor routers directory * move func used for web and api to common * make corsHandler a function to prohibit side efects * rm unused func Co-authored-by: 6543 <6543@obermui.de>
* Add Image Diff for SVG files (#14867)KN4CK3R2021-06-051-15/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Added type sniffer. * Switched content detection from base to typesniffer. * Added GuessContentType to Blob. * Moved image info logic to client. Added support for SVG images in diff. * Restore old blocked svg behaviour. * Added missing image formats. * Execute image diff only when container is visible. * add margin to spinner * improve BIN tag on image diffs * Default to render view. * Show image diff on incomplete diff. Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Lauris BH <lauris@nix.lv>
* Add mimetype mapping settings (#15133)Adam Szatyin2021-05-101-0/+8
| | | | | | | | | | | | | * Fix APK's Content-Type header * Fix case sensitive comparison * Add custom mime type mapping for downloadable files * Add documentation for MIME type mapping * Rename download.mimetype.mapping configuration to repository.mimetype_mapping Co-authored-by: zeripath <art27@cantab.net>
* On open repository open common cat file batch and batch-check (#15667)zeripath2021-05-101-0/+12
| | | | | | | Use common git cat-file --batch and git cat-file --batch-check to significantly reduce calls to git. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add ETag header (#15370)KN4CK3R2021-04-121-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | * Add ETag header. * Comply with RFC 7232. * Moved logic into httpcache.go * Changed name. * Lint * Implemented If-None-Match list. * Fixed missing header on * * Removed weak etag support. * Removed * support. * Added unit test. * Lint Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Add LFS Migration and Mirror (#14726)KN4CK3R2021-04-081-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implemented LFS client. * Implemented scanning for pointer files. * Implemented downloading of lfs files. * Moved model-dependent code into services. * Removed models dependency. Added TryReadPointerFromBuffer. * Migrated code from service to module. * Centralised storage creation. * Removed dependency from models. * Moved ContentStore into modules. * Share structs between server and client. * Moved method to services. * Implemented lfs download on clone. * Implemented LFS sync on clone and mirror update. * Added form fields. * Updated templates. * Fixed condition. * Use alternate endpoint. * Added missing methods. * Fixed typo and make linter happy. * Detached pointer parser from gogit dependency. * Fixed TestGetLFSRange test. * Added context to support cancellation. * Use ReadFull to probably read more data. * Removed duplicated code from models. * Moved scan implementation into pointer_scanner_nogogit. * Changed method name. * Added comments. * Added more/specific log/error messages. * Embedded lfs.Pointer into models.LFSMetaObject. * Moved code from models to module. * Moved code from models to module. * Moved code from models to module. * Reduced pointer usage. * Embedded type. * Use promoted fields. * Fixed unexpected eof. * Added unit tests. * Implemented migration of local file paths. * Show an error on invalid LFS endpoints. * Hide settings if not used. * Added LFS info to mirror struct. * Fixed comment. * Check LFS endpoint. * Manage LFS settings from mirror page. * Fixed selector. * Adjusted selector. * Added more tests. * Added local filesystem migration test. * Fixed typo. * Reset settings. * Added special windows path handling. * Added unit test for HTTPClient. * Added unit test for BasicTransferAdapter. * Moved into util package. * Test if LFS endpoint is allowed. * Added support for git:// * Just use a static placeholder as the displayed url may be invalid. * Reverted to original code. * Added "Advanced Settings". * Updated wording. * Added discovery info link. * Implemented suggestion. * Fixed missing format parameter. * Added Pointer.IsValid(). * Always remove model on error. * Added suggestions. * Use channel instead of array. * Update routers/repo/migrate.go * fmt Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net>
* Add Content-Length header to HEAD requests (#14542)Farid AYOUJIL2021-02-051-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add Content-Length header to HEAD requests This change adds the header Content-Length to HEAD HTTP requests. The previous behaviour was blocking some Windows executables (i.e bitsadmin.exe) from downloading files hosted in Gitea. This along with PR #14541, makes the web server compliant with HTTP RFC 2616 which states "The methods GET and HEAD MUST be supported by all general-purpose servers" and "The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response." This should also respond to issues #8030 and #14532. * This change adds the header Content-Length to HEAD HTTP requests Pass the Size of the content as a parameter to ServeData() instead of calculating it using ioutil.ReadAll(reader) --> this call is dangerous and can result in a denial of service. * Add Content-Length header to HEAD requests Quick fix for imported dependency not used. * Check if size is positiv int ... Co-authored-by: zeripath <art27@cantab.net>
* Display SVG files as images instead of text (#14101)Jonathan Tran2021-01-121-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Change to display SVG files as images * Remove unsafe styles from SVG CSP * Add integration test to test SVG headers * Add config setting to disable SVG rendering * Add test for img tag when loading SVG image * Remove the Raw view button for svg files since we don't fully support this * Fix copyright year * Rename and move config setting * Add setting to cheat sheet in docs * Fix so that comment matches cheat sheet * Add allowing styles in CSP based on pull request feedback * Re-enable raw button since we show SVG styles now * Change so that SVG files are editable * Add UI to toggle between source and rendered image for SVGs * Change to show blame button for SVG images * Fix to update ctx data * Add test for DetectContentType when file is longer than sniffLen Co-authored-by: Jonathan Tran <jon@allspice.io> Co-authored-by: Kyle D <kdumontnu@gmail.com>
* Update golangci-lint to version 1.31.0 (#13102)kolaente2020-10-111-1/+1
| | | | | | | This PR updates golangci-lint to the latest version 1.31.0. The upgrade introduced a new check for which I've fixed or disabled most cases. Signed-off-by: kolaente <k@knt.li>
* Add a storage layer for attachments (#11387)Lunny Xiao2020-08-181-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add a storage layer for attachments * Fix some bug * fix test * Fix copyright head and lint * Fix bug * Add setting for minio and flags for migrate-storage * Add documents * fix lint * Add test for minio store type on attachments * fix test * fix test * Apply suggestions from code review Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com> * Add warning when storage migrated successfully * Fix drone * fix test * rebase * Fix test * display the error on console * Move minio test to amd64 since minio docker don't support arm64 * refactor the codes * add trace * Fix test * remove log on xorm * Fi download bug * Add a storage layer for attachments * Add setting for minio and flags for migrate-storage * fix lint * Add test for minio store type on attachments * Apply suggestions from code review Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com> * Fix drone * fix test * Fix test * display the error on console * Move minio test to amd64 since minio docker don't support arm64 * refactor the codes * add trace * Fix test * Add URL function to serve attachments directly from S3/Minio * Add ability to enable/disable redirection in attachment configuration * Fix typo * Add a storage layer for attachments * Add setting for minio and flags for migrate-storage * fix lint * Add test for minio store type on attachments * Apply suggestions from code review Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com> * Fix drone * fix test * Fix test * display the error on console * Move minio test to amd64 since minio docker don't support arm64 * don't change unrelated files * Fix lint * Fix build * update go.mod and go.sum * Use github.com/minio/minio-go/v6 * Remove unused function * Upgrade minio to v7 and some other improvements * fix lint * Fix go mod Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: Tyler <tystuyfzand@gmail.com>
* Add Access-Control-Expose-Headers (#12446)zeripath2020-08-131-0/+2
| | | | | | Fix #12424 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io>
* Fix download file wrong content-type (#9825)Lunny Xiao2020-01-171-1/+7
| | | | | | | | * Fix download file wrong content-type * change the error text to be more precise * fix test
* Add missed close in ServeBlobLFS (#8527)zeripath2019-10-161-0/+5
|
* Add golangci (#6418)kolaente2019-06-121-4/+16
|
* move code.gitea.io/git to code.gitea.io/gitea/modules/git (#6364)Lunny Xiao2019-03-271-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * move code.gitea.io/git to code.gitea.io/gitea/modules/git * fix imports * fix fmt * fix misspell * remove wrong tests data * fix unit tests * fix tests * fix tests * fix tests * fix tests * fix tests * enable Debug to trace the failure tests * fix tests * fix tests * fix tests * fix tests * fix tests * comment commit count tests since git clone depth is 50 * fix tests * update from code.gitea.io/git * revert change to makefile
* Allow markdown files to read from the LFS (#5787)zeripath2019-02-121-0/+56
| | | | | | | This PR makes it possible for the markdown renderer to render images and media straight from the LFS. Fix #5746 Signed-off-by: Andrew Thornton [art27@cantab.net](mailto:art27@cantab.net)
* Add raw blob endpoint to get objects by SHA ID (#5334)Peter Hoffmann2018-11-181-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Add raw blob endpoint This should make it possible to download raw blobs directly from /:repo/:username/raw/blob/:sha1 URLs. * fix: Make it work * As an SHA-ID is no path getRefNameFromPath can't be used to verify file specifying parameter * added relevant change in go-gitea/git #132 Signed-off-by: Berengar W. Lehr <Berengar.Lehr@kompetenztest.de> * Update Gopkg.lock Can't update all vendors due to errors Signed-off-by: Berengar W. Lehr <Berengar.Lehr@kompetenztest.de> * style: Add Gitea copyright header * feat: Added integration test for /repo/u/r/raw/blob * fix: correct year in copyright header
* Handle refactor (#3339)Morgan Bazalgette2018-01-101-3/+3
| | | | | | * Replace all ctx.Handle with ctx.ServerError or ctx.NotFound * Change Handle(403) to NotFound, avoid using macaron's NotFound
* Memory usage improvements (#3013)Duncan Ogilvie2017-11-291-1/+2
| | | | | | | | | | * govendor update code.gitea.io/git Signed-off-by: Duncan Ogilvie <mr.exodia.tpodt@gmail.com> * Greatly improve memory usage Signed-off-by: Duncan Ogilvie <mr.exodia.tpodt@gmail.com>
* Download files to their original filename (#1676)silverwind2017-05-051-0/+2
|
* Fix empty file download (#1506)Lauris BH2017-04-201-1/+1
|
* Fix Chrome not liking commasAndrey Nering2016-11-261-0/+4
|
* Fix HTTP headers for issue attachment downloadAndrey Nering2016-11-261-7/+9
| | | | | - Download filename was wrong for files other than images. Example: It was `download` instead of `file.pdf` - PDF was downloading instead of showing on browser
* golint fixed for routers (#208)Lunny Xiao2016-11-241-0/+3
|
* Update import paths from github.com/go-gitea to code.gitea.io (#135)Sandro Santilli2016-11-101-3/+3
| | | | | | | - Update import paths from github.com/go-gitea to code.gitea.io - Fix import path for travis See https://docs.travis-ci.com/user/languages/go#Go-Import-Path
* Replace gogits/git-module dependency with go-gitea/git (#94)Sandro Santilli2016-11-061-1/+1
| | | | | | | | * Replace gogits/git-module dependency with go-gitea/git Fixes #92 * Remove git alias for git module import (not needed)
* Change import reference to match gitea instead of gogs (#37)Rémy Boulanouar2016-11-031-2/+2
|
* router/repo: code refactoringUnknwon2016-08-301-4/+2
|
* Web editor: improve code qualityUnknwon2016-08-241-3/+3
|
* #2593 allow render raw contentUnknwon2016-08-051-1/+1
| | | | Use URL query parameter render=1 to render content in raw mode.
* Set utf-8 charset for text files when serving raw content (#2898)Tamás Molnár2016-04-201-1/+1
|
* #2842 add quotes to attachment file nameUnknwon2016-03-251-1/+1
|
* Rename module: middleware -> contextUnknwon2016-03-111-4/+4
|
* #2283 set text/plain for non-binary files in raw modeUnknwon2015-12-251-0/+2
|
* rename import pathUnknwon2015-12-151-1/+1
|
* move out git module and #1573 send push hookUnknwon2015-12-091-3/+4
|
* Merge pull request #1485 from donbowman/mime-type无闻2015-08-141-6/+1
|\ | | | | 43bfee0d4872932c1da185e8367e21795bc4ceb5 reverted my change
| * 43bfee0d4872932c1da185e8367e21795bc4ceb5 reverted my changeDon Bowman2015-08-131-6/+1
| | | | | | | | | | | | 423b1c69be7828c331a47467b66217d190e916b9, which in turn causes all content to be served as text/plain. Let go decide what the mime type is (e.g. text/html instead of text/plain).
* | fix serve attachment content typeUnknwon2015-08-121-8/+12
|/
* Fix UTF-8 in upper-case, use ansi charset for all non UTF-8 encodingsVladimir Vissoultchev2015-07-291-1/+1
|
* Raw text file view returns correct charset in content-type header if not utf-8Vladimir Vissoultchev2015-07-281-4/+11
|
* don't set mime type to text/plain. This will break serving e.g. raw images,Don Bowman2015-04-081-1/+0
| | | | | | | | | html, etc According to http://golang.org/pkg/net/http/#DetectContentType "If the Header does not contain a Content-Type line, Write adds a Content-Type set to the result of passing the initial 512 bytes of written data to DetectContentType."
* routers/repo: set raw page content type to 'text/plain' #828Unknwon2015-01-311-4/+4
|
* GetFile apiUnknwon2014-11-161-9/+19
|
* Fix #605, fix #255, fix #101Unknwon2014-11-061-5/+3
|
* Huge updates!!!!! Be careful to merge!!!!Unknwon2014-07-261-41/+32
|
* New UI merge in progressUnknwon2014-07-261-91/+40
|
* Fixed directory permissions for the zip download routerJan Oliver Oelerich2014-06-011-1/+1
| | | If the archives/ directory is created with 0655, it results in a permission error.
* fix for new git apislene2014-05-281-4/+16
|
* Fixed #209Unknown2014-05-251-12/+9
|