From 02c3e617aee14164a7949986d5ebf1c57b1c0be6 Mon Sep 17 00:00:00 2001 From: Alex Taber Date: Mon, 14 Jun 2021 13:03:57 -0400 Subject: [PATCH] Handle when content-disposition header is not present --- source/remote.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/remote.c b/source/remote.c index ade0d50..cac7cd2 100644 --- a/source/remote.c +++ b/source/remote.c @@ -852,17 +852,22 @@ static ParseResult parse_header(struct header * out, httpcContext * context, con if (out->filename) { + bool present = 1; out->result_code = httpcGetResponseHeader(context, "Content-Disposition", content_buf, 1024); if (R_FAILED(out->result_code)) { - DEBUG("httpcGetResponseHeader\n"); - return HTTPC_ERROR; + if (out->result_code == 0xD8A0A028) + present = 0; + else + { + DEBUG("httpcGetResponseHeader\n"); + return HTTPC_ERROR; + } } // content_buf: Content-Disposition: attachment; ... filename=;? ... - char * filename = strstr(content_buf, "filename="); // filename=;? ... - if (!filename) + if (!present) { const int max_chars = 250; // needs to be heap allocated only because the call site is expected to free it @@ -891,6 +896,7 @@ static ParseResult parse_header(struct header * out, httpcContext * context, con return SUCCESS; } + char * filename = strstr(content_buf, "filename="); // filename=;? ... filename = strpbrk(filename, "=") + 1; // ;? char * end = strpbrk(filename, ";"); if (end)