Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
allow redirection
Browse files Browse the repository at this point in the history
  • Loading branch information
ksanislo committed Feb 24, 2016
1 parent 7b74a4d commit f8c92c5
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include <stdio.h>
#include <inttypes.h>

// Max URL length used in qr variation
#define QUIRC_MAX_PAYLOAD 8896

using namespace ctr;

bool onProgress(u64 pos, u64 size) {
Expand Down Expand Up @@ -41,6 +44,12 @@ Result http_getinfo(char *url, app::App *app) {
ret = httpcGetResponseStatusCode(&context, &statuscode, 0);
if(ret!=0)return ret;

if(statuscode==301||statuscode==302) {
if(httpcGetResponseHeader(&context, (char*)"Location", (char*)url, QUIRC_MAX_PAYLOAD-1)==0){
return http_getinfo(url, app);
}
}

if(statuscode!=206)return -2; // 206 Partial Content

u8 *buf = (u8*)malloc(8); // Allocate u8*8 == u64
Expand Down Expand Up @@ -120,10 +129,12 @@ int main(int argc, char **argv)

app::App app;

//Change this to your own URL.
char *url = (char*)"http://3ds.intherack.com/files/QRWebLoader_0.5.0.cia";
char *url = (char*)malloc(QUIRC_MAX_PAYLOAD);

// Change this to your own URL.
strcpy(url, "http://3ds.intherack.com/files/QRWebLoader_0.5.1.cia");

printf("Downloading %s\n",url);
printf("Downloading %s\n", url);
gpu::flushBuffer();

ret = http_getinfo(url, &app);
Expand Down

0 comments on commit f8c92c5

Please sign in to comment.