u/Dull_Firefighter_929

HTTP Sending Error

Bonjour, j'essaie d'envoyer le contenu brut d'un fichier, mais je ne comprends pas pourquoi : lorsque le fichier fait 5 Mo, seuls 3,7 Mo sont envoyés et la connexion est réinitialisée. Si j'envoie un fichier de 2 Mo, seuls 300 ko sont envoyés et la connexion est réinitialisée en cours de route. Je sais que mon code n'est pas parfait et que je ne teste pas toutes les erreurs de lecture et d'écriture. Mais je ne comprends pas ces erreurs. J'utilise un navigateur pour afficher les résultats.

Voici un extrait du code, cette partie sert à envoyer les paquets :

int count1 = 0;
while (count1 < size_buffer + size_header) {
    int n = write(new_sock, buffer + count1, size_buffer + size_header - count1);
    if (n == -1) {
        perror("write()");
        break;
    }
    count1 += n;
}

Voici l'en-tête que j'envoie au début de la requête. Il se peut que certains en-têtes soient manquants ; je vous ai épargné tout le code. J'ai constaté qu'avec les petits fichiers, l'envoi se fait correctement.

char *header = malloc(512);
int size_header = sprintf(header, "HTTP/1.1 200 \r\ncontent-type: text/plain; charset=utf-8\r\naccess-control-allow-origin: *\r\ncross-origin-resource-policy: cross-origin\r\ncontent-length: %ld\r\n\r\n", size_buffer);
header = realloc(header, size_header);

Voici ce que m'indique le navigateur :

État
200
Version HTTP/1.1
Transfert 325,63 Ko (taille 325,47 Ko)
Priorité de la requête : Élevée
Résolution DNS : Système
access-control-allow-origin

content-length
2447363
content-type
text/plain; charset=utf-8
cross-origin-resource-policy
cross-origin

Et j'obtiens l'erreur NS_ERROR_NET_RESET.

Si vous connaissez la cause du problème, merci.

Merci d'avance pour votre aide.
reddit.com
u/Dull_Firefighter_929 — 4 days ago
▲ 0 r/pihole

Les bases de données de Pi-hole sont basées sur sqlite3. Or, lorsque je tape la commande sqlite3 dans le terminal de mon Raspberry Pi, elle est introuvable ? Je souhaite examiner le fichier gravity.db.

reddit.com
u/Dull_Firefighter_929 — 6 days ago
▲ 7 r/pihole

Pi-hole doesn't send CORS headers on failed authentication

When calling the Pi-hole API /api/auth with a wrong password, Pi-hole doesn't include CORS headers in the response.

The result: impossible to distinguish between these three cases:

The box is unreachable

The password is wrong

An actual network error

All three situations look identical on the client side just a failed request with no useful information. It would be great if Pi-hole consistently sent CORS headers even on authentication failures.

Has anyone else noticed this?

reddit.com
u/Dull_Firefighter_929 — 11 days ago
▲ 0 r/pihole

hello I use the pi hole API for a dashbord that restores all my connected devices, until now the pi hole api works perfectly, but I noticed that when I make a POST requette to this url http://${pi_hole}/api/auth { password: my_pass} to get a SID, well when I provide the right password everything works, but if I get it wrong I end up with a CORS error, the CORS header "Access-Control-Allow-Origin" is missing. Status Code: 204. Do you know why? I have the impression that the mistake is an impassable thing that everyone fears

reddit.com
u/Dull_Firefighter_929 — 13 days ago
▲ 0 r/pihole

Hello, after some of my friends saw how effective a Pi-hole is, they want me to install one at their place. However, they don’t know anything about Pi-hole and don’t want to deal with it themselves. Do you have any idea which blocking list I could use something lightweight so they don’t end up calling me saying Facebook or other websites aren’t working? If you have any suggestions, I’d appreciate it.

reddit.com
u/Dull_Firefighter_929 — 15 days ago

hello I try to use Chart.js in my project, so I included in the html file , in the <head>

"<link rel="stylesheet" href="app.css">

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.5.0/chart.min.js" defer></script>

<script src="app.js" defer></script>"

don't do anything yet in my javascript file but I have the error "import declarations may only appear at top level of a module" in the console, I don't understand, thank you for your help.

reddit.com
u/Dull_Firefighter_929 — 15 days ago