Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hi,

ich habe folgendes Programm, mit dem ich eine Datei von einem Webserver

runterladen möchte. Allerdings gibt es noch ein Problem, ich sitze hier hinter einem

Proxyserver und wenn ich HttpSendRequest() aufrufe, bekomme ich den Fehler das

ich mich erst am Proxy anmelden muß. Wenn ich das dann erledigt habe und

HttpSendRequest() erneut aufrufe, bekomme ich jedesmal einen Timeout.

Wenn ich bei InternetOpen angebe das ich hinter einen Proxy sitze (ohne den

Namen anzugeben), läuft das Programm wenn auf dem PC der Microsoft Proxy Client

installiert ist, ohne das ich mich anmelden muss. Ansonsten kann er die Adresse nicht auflösen.

Wenn ich bei InernetOpen zusätzlich noch den Namen des Proxys angeben, habe ich

das selbe Problem wie wenn ich nichts angebe.

:confused:

Hier habt ihr mal den gesamten Code:


#include <stdio.h>
#include <conio.h>
#include <windows.h>
#include <wininet.h>

#pragma comment(lib,"wininet.lib")

main()
{
HINTERNET hInternet;
HINTERNET hConnect;
HINTERNET hRequest;
DWORD dwRead =1;
char c[1000];

hInternet = InternetOpen("Microsoft Internet Explorer",NULL,NULL,NULL,NULL);
if (hInternet == NULL)
{
printf ("fehler1\n");
}
else
{
printf ("ok\n");
hConnect = InternetConnect(hInternet,"xxx.yyy.zzz",INTERNET_DEFAULT_HTTP_PORT,
"","",INTERNET_SERVICE_HTTP,
NULL,NULL);

if (hConnect == NULL)
{
printf ("fehler2\n");
}
else
{

printf ("ok\n");
hRequest = HttpOpenRequest(hConnect,NULL,"test/test2/test.zip",NULL,"",
NULL,NULL,NULL);
if (hRequest == NULL)
{
printf ("fehler3\n");
}
else
{
printf ("ok\n");
ok:
if (!HttpSendRequest(hRequest,NULL,NULL,NULL,NULL))
{
DWORD er,w=1000;
char r[1000];
InternetGetLastResponseInfo(&er,r,&w);
printf ("\n%s -> %i",r,er);
printf ("nicht gesendet->%i",GetLastError());
}
else
{
DWORD dwCode,dwSize=40;
if (HttpQueryInfo(hRequest,HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER,
&dwCode,&dwSize,NULL))
printf ("query\n");
if (dwCode == HTTP_STATUS_PROXY_AUTH_REQ)
{
printf ("anmelden!\n");
dwRead = 1;
while(dwRead != NULL)
if (!InternetReadFile(hRequest,c,1000,&dwRead))
printf ("\nkann nicht lesen->%i",GetLastError());
if (InternetErrorDlg (GetDesktopWindow(),hRequest, ERROR_INTERNET_INCORRECT_PASSWORD,
FLAGS_ERROR_UI_FILTER_FOR_ERRORS | FLAGS_ERROR_UI_FLAGS_GENERATE_DATA |
FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS,NULL) == ERROR_INTERNET_FORCE_RETRY)
{
printf ("neuer versuch\n");
goto ok;
}
else
{
printf ("chanceld\n");
}
}
else
{
printf ("gesendet\n");

FILE* stream = fopen("c:\\update.zip","wb");
if (stream == NULL)
printf ("kann datei nicht erstellen\n");
else
{
dwRead=1;
while(dwRead != NULL)
{
if (InternetReadFile(hRequest,c,1000,&dwRead) == false)
{
printf ("kann nicht lesen->%i",GetLastError());
dwRead = NULL;
}
else
{
fwrite(c,sizeof(char),dwRead,stream);
printf ("schreibe: %i\n",dwRead);
}
}
fclose(stream);
}
}
}
InternetCloseHandle(hRequest);
}
InternetCloseHandle(hConnect);
}
InternetCloseHandle(hInternet);

}
printf ("\nfertig\n");
getch();
return 0;
}
[/PHP]

Das war zwar jetzt alles ein bischen viel, aber ich hoffe das mir trotzdem jemand helfen kann.

Gruß

Guybrush

PS: Das goto bleibt natürlich nur in der Testversion drin;)

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.