API: support HEAD requests #854

Closed
opened 2025-11-02 03:39:06 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @stephenc on GitHub (Jun 29, 2017).

  • Gitea version (or commit ref): 858197b
  • Git version: N/A
  • Operating system: N/A
  • Database (use [x]): N/A
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL) https://try.gitea.io/api/v1/version
    • No
    • Not relevant
  • Log gist:

Description

The API does not correctly respond to HEAD requests for valid GET URLs, e.g.

$ curl -v https://try.gitea.io/api/v1/version
*   Trying 159.203.182.191...
* TCP_NODELAY set
* Connected to try.gitea.io (159.203.182.191) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: try.gitea.io
* Server certificate: Let's Encrypt Authority X3
* Server certificate: DST Root CA X3
> GET /api/v1/version HTTP/1.1
> Host: try.gitea.io
> User-Agent: curl/7.51.0
> Accept: */*
> 
< HTTP/1.1 200 OK
...
$ $ curl -I -v https://try.gitea.io/api/v1/version
*   Trying 159.203.182.191...
* TCP_NODELAY set
* Connected to try.gitea.io (159.203.182.191) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: try.gitea.io
* Server certificate: Let's Encrypt Authority X3
* Server certificate: DST Root CA X3
> HEAD /api/v1/version HTTP/1.1
> Host: try.gitea.io
> User-Agent: curl/7.51.0
> Accept: */*
> 
< HTTP/1.1 404 Not Found
...

Screenshots

N/A

Originally created by @stephenc on GitHub (Jun 29, 2017). - Gitea version (or commit ref): 858197b - Git version: N/A - Operating system: N/A - Database (use `[x]`): N/A - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] Yes (provide example URL) `https://try.gitea.io/api/v1/version` - [ ] No - [ ] Not relevant - Log gist: ## Description The API does not correctly respond to HEAD requests for valid GET URLs, e.g. ``` $ curl -v https://try.gitea.io/api/v1/version * Trying 159.203.182.191... * TCP_NODELAY set * Connected to try.gitea.io (159.203.182.191) port 443 (#0) * TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 * Server certificate: try.gitea.io * Server certificate: Let's Encrypt Authority X3 * Server certificate: DST Root CA X3 > GET /api/v1/version HTTP/1.1 > Host: try.gitea.io > User-Agent: curl/7.51.0 > Accept: */* > < HTTP/1.1 200 OK ... $ $ curl -I -v https://try.gitea.io/api/v1/version * Trying 159.203.182.191... * TCP_NODELAY set * Connected to try.gitea.io (159.203.182.191) port 443 (#0) * TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 * Server certificate: try.gitea.io * Server certificate: Let's Encrypt Authority X3 * Server certificate: DST Root CA X3 > HEAD /api/v1/version HTTP/1.1 > Host: try.gitea.io > User-Agent: curl/7.51.0 > Accept: */* > < HTTP/1.1 404 Not Found ... ``` ## Screenshots N/A
GiteaMirror added the type/proposal label 2025-11-02 03:39:06 -06:00
Author
Owner

@sapk commented on GitHub (Jan 16, 2020):

This is now implemented if I am not mistaken

To valide I re-use your command and we get a 200 on HEAD request

bash-5.0# curl -I -v https://try.gitea.io/api/v1/version
*   Trying 167.99.148.217:443...
* TCP_NODELAY set
* Connected to try.gitea.io (167.99.148.217) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: none
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=try.gitea.io
*  start date: Nov 26 13:36:05 2019 GMT
*  expire date: Feb 24 13:36:05 2020 GMT
*  subjectAltName: host "try.gitea.io" matched cert's "try.gitea.io"
*  issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x55a9ab3981c0)
> HEAD /api/v1/version HTTP/2
> Host: try.gitea.io
> user-agent: curl/7.67.0
> accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 250)!
< HTTP/2 200
HTTP/2 200
< content-type: application/json; charset=UTF-8
content-type: application/json; charset=UTF-8
< date: Thu, 16 Jan 2020 11:30:35 GMT
date: Thu, 16 Jan 2020 11:30:35 GMT
< set-cookie: lang=en-US; Path=/; Max-Age=2147483647
set-cookie: lang=en-US; Path=/; Max-Age=2147483647
< set-cookie: i_like_gitea=a8ffa7443b1d49b2; Path=/; HttpOnly
set-cookie: i_like_gitea=a8ffa7443b1d49b2; Path=/; HttpOnly
< set-cookie: _csrf=sOyhKbNv--o87Ocu2zj3IqeA6W86MTU3OTE3NDIzNTkwMTQzODI1Ng; Path=/; Expires=Fri, 17 Jan 2020 11:30:35 GMT; HttpOnly
set-cookie: _csrf=sOyhKbNv--o87Ocu2zj3IqeA6W86MTU3OTE3NDIzNTkwMTQzODI1Ng; Path=/; Expires=Fri, 17 Jan 2020 11:30:35 GMT; HttpOnly
< x-content-type-options: nosniff
x-content-type-options: nosniff
< x-frame-options: SAMEORIGIN
x-frame-options: SAMEORIGIN
@sapk commented on GitHub (Jan 16, 2020): This is now implemented if I am not mistaken To valide I re-use your command and we get a 200 on HEAD request ``` bash-5.0# curl -I -v https://try.gitea.io/api/v1/version * Trying 167.99.148.217:443... * TCP_NODELAY set * Connected to try.gitea.io (167.99.148.217) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: none * TLSv1.3 (OUT), TLS handshake, Client hello (1): * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (IN), TLS handshake, Server key exchange (12): * TLSv1.2 (IN), TLS handshake, Server finished (14): * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1): * TLSv1.2 (OUT), TLS handshake, Finished (20): * TLSv1.2 (IN), TLS handshake, Finished (20): * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256 * ALPN, server accepted to use h2 * Server certificate: * subject: CN=try.gitea.io * start date: Nov 26 13:36:05 2019 GMT * expire date: Feb 24 13:36:05 2020 GMT * subjectAltName: host "try.gitea.io" matched cert's "try.gitea.io" * issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3 * SSL certificate verify ok. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * Using Stream ID: 1 (easy handle 0x55a9ab3981c0) > HEAD /api/v1/version HTTP/2 > Host: try.gitea.io > user-agent: curl/7.67.0 > accept: */* > * Connection state changed (MAX_CONCURRENT_STREAMS == 250)! < HTTP/2 200 HTTP/2 200 < content-type: application/json; charset=UTF-8 content-type: application/json; charset=UTF-8 < date: Thu, 16 Jan 2020 11:30:35 GMT date: Thu, 16 Jan 2020 11:30:35 GMT < set-cookie: lang=en-US; Path=/; Max-Age=2147483647 set-cookie: lang=en-US; Path=/; Max-Age=2147483647 < set-cookie: i_like_gitea=a8ffa7443b1d49b2; Path=/; HttpOnly set-cookie: i_like_gitea=a8ffa7443b1d49b2; Path=/; HttpOnly < set-cookie: _csrf=sOyhKbNv--o87Ocu2zj3IqeA6W86MTU3OTE3NDIzNTkwMTQzODI1Ng; Path=/; Expires=Fri, 17 Jan 2020 11:30:35 GMT; HttpOnly set-cookie: _csrf=sOyhKbNv--o87Ocu2zj3IqeA6W86MTU3OTE3NDIzNTkwMTQzODI1Ng; Path=/; Expires=Fri, 17 Jan 2020 11:30:35 GMT; HttpOnly < x-content-type-options: nosniff x-content-type-options: nosniff < x-frame-options: SAMEORIGIN x-frame-options: SAMEORIGIN ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#854