Closed eldk closed 5 years ago
Bonjour,
Avez-vous un exemple de requête qui ne renvoie pas cet en-tête ? J'ai fait quelques essais et l'en-tête est bien retourné.
Bonsoir,
1 - La requête d'initialisation (OPTIONS) :
curl -I 'https://geo.api.gouv.fr/communes?codePostal=75018&fields=codesPostaux,departement,region&boost=population' -X OPTIONS -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0' -H 'Accept: */*' -H 'Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3' --compressed -H 'Access-Control-Request-Method: GET' -H 'Access-Control-Request-Headers: content-type' -H 'Referer: http://domain.tld/new/page.html' -H 'Origin: http://domain.tld' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'TE: Trailers'
En-têtes de requête :
Host: geo.api.gouv.fr
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: */*
Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Access-Control-Request-Method: GET
Access-Control-Request-Headers: content-type
Referer: http://domain.tld/new/page.html
Origin: http://domain.tld
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
TE: Trailers
En-têtes de réponse :
HTTP/2.0 204 No Content
server: nginx/1.10.3 (Ubuntu)
date: Wed, 24 Jul 2019 19:34:50 GMT
x-powered-by: Express
access-control-allow-origin: *
access-control-allow-methods: GET,HEAD,PUT,PATCH,POST,DELETE
vary: Access-Control-Request-Headers
access-control-allow-headers: content-type
strict-transport-security: max-age=15552000
X-Firefox-Spdy: h2
2 - La requête de récupération des données (GET) :
curl -I 'https://geo.api.gouv.fr/communes?codePostal=75018&fields=codesPostaux,departement,region&boost=population' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0' -H 'Accept: application/json' -H 'Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3' --compressed -H 'Referer: http://domain.tld/new/page.html' -H 'Content-Type: application/json' -H 'Origin: http://domain.tld' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'TE: Trailers'
En-têtes de requête :
Host: geo.api.gouv.fr
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: */*
Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Access-Control-Request-Method: GET
Access-Control-Request-Headers: content-type
Referer: http://domain.tld/new/page.html
Origin: http://domain.tld
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
TE: Trailers
En-têtes de réponse :
HTTP/2.0 200 OK
server: nginx/1.10.3 (Ubuntu)
date: Wed, 24 Jul 2019 19:34:50 GMT
content-type: application/json; charset=utf-8
vary: Accept-Encoding
x-powered-by: Express
access-control-allow-origin: *
etag: W/"129-5/C8ODhjmMcC6clp5+gcHa8M6lY"
strict-transport-security: max-age=15552000
content-encoding: gzip
X-Firefox-Spdy: h2
Je n'ai pas de "content-length" ici non plus :
curl -I 'https://geo.api.gouv.fr/communes?nom=saint&fields=nom,code,codesPostaux,codeDepartement,codeRegion,population&format=json&geometry=centre' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0' -H 'Accept: application/json' -H 'Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3' --compressed -H 'Referer: https://api.gouv.fr/api/api-geo.html' -H 'Origin: https://api.gouv.fr' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'TE: Trailers'
HTTP/1.1 200 OK
Server: nginx/1.10.3 (Ubuntu)
Date: Wed, 24 Jul 2019 21:11:21 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: Express
Access-Control-Allow-Origin: *
ETag: W/"ac5c4-86n6xwwPS5oDQZcCnEXzxi3mZgU"
Strict-Transport-Security: max-age=15552000
Content-Encoding: gzip
Cordialement,
Eric
Si la compression est désactivée, le header content-length est bien présent :
curl -I 'https://geo.api.gouv.fr/communes?nom=saint&fields=nom,code,codesPostaux,codeDepartement,codeRegion,population&format=json&geometry=centre' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0' -H 'Accept: application/json' -H 'Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3' -H 'Referer: https://api.gouv.fr/api/api-geo.html' -H 'Origin: https://api.gouv.fr' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'TE: Trailers'
HTTP/1.1 200 OK
Server: nginx/1.10.3 (Ubuntu)
Date: Wed, 24 Jul 2019 21:24:04 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 705988
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: Express
Access-Control-Allow-Origin: *
ETag: W/"ac5c4-86n6xwwPS5oDQZcCnEXzxi3mZgU"
Strict-Transport-Security: max-age=15552000
Merci,
Eric
Bonjour,
Est-il possible d'ajouter "content-length" aux en-têtes de réponse du serveur de l'API ?
Cordialement,
Eric