Download raw body.
gotwebd: set filename for RSS feeds
On 23-01-03 03:47PM, Omar Polo wrote: > On 2023/01/03 22:43:26 +1100, Mark Jamsek <mark@jamsek.com> wrote: > > On 23-01-03 12:22PM, Omar Polo wrote: > > > a consequence i haven't realized when adding RSS support is that since > > > gotwebd serves the pages from a path that's lacking a filename part, > > > the browser call the RSS feed with a random string. > > > > > > This is not an issue for RSS readers (they extract all the needed info > > > from the XML), but it's ugly, so let's fix it. > > > > > > Diff below uses Content-Disposition to 1) make the browser download > > > the file instead of rendering it and 2) use a reasonable file name > > > (got.git.rss) instead of the random string the browser will use > > > otherwise (lHFP5B6d). > > > > > > ok? > > > > good catch! nice. ok > > Thanks! > > I wasn't sure about adding that extra PATH_MAX local buffer, since > gotweb_render_content_type_file is just a glorified printf here's an > equivalent diff that passes an extra "suffix" parameter. What do you > think? this is better, imo. ok > diff /home/op/w/got2 > commit - 1b18f4cd75fddf070589d9b045e083ac02d8baba > path + /home/op/w/got2 > blob - 89718fdd602637e74ca5a949af1e7cfda57b723d > file + gotwebd/got_operations.c > --- gotwebd/got_operations.c > +++ gotwebd/got_operations.c > @@ -1044,7 +1044,7 @@ got_output_file_blob(struct request *c) > if (isbinary(buf, len - hdrlen)) { > error = gotweb_render_content_type_file(c, > "application/octet-stream", > - qs->file); > + qs->file, NULL); > if (error) { > log_warnx("%s: %s", __func__, > error->msg); > blob - 6f5a07850b9e8e153830292e5ce4f4d986782eff > file + gotwebd/gotweb.c > --- gotwebd/gotweb.c > +++ gotwebd/gotweb.c > @@ -179,8 +179,9 @@ gotweb_process_request(struct request *c) > } > > if (qs->action == RSS) { > - error = gotweb_render_content_type(c, > - "application/rss+xml;charset=utf-8"); > + error = gotweb_render_content_type_file(c, > + "application/rss+xml;charset=utf-8", > + repo_dir->name, ".rss"); > if (error) { > log_warnx("%s: %s", __func__, error->msg); > goto err; > @@ -670,11 +671,11 @@ gotweb_render_content_type_file(struct request *c, con > > const struct got_error * > gotweb_render_content_type_file(struct request *c, const char *type, > - const char *file) > + const char *file, const char *suffix) > { > fcgi_printf(c, "Content-type: %s\r\n" > - "Content-disposition: attachment; filename=%s\r\n\r\n", > - type, file); > + "Content-disposition: attachment; filename=%s%s\r\n\r\n", > + type, file, suffix ? suffix : ""); > return NULL; > } > > blob - 8a9deffd75b83126733cb4d76bb9170bc7604995 > file + gotwebd/gotwebd.h > --- gotwebd/gotwebd.h > +++ gotwebd/gotwebd.h > @@ -437,7 +437,7 @@ const struct got_error > const uint8_t *); > const struct got_error > *gotweb_render_content_type_file(struct request *, const char *, > - const char *); > + const char *, const char *); > void gotweb_get_navs(struct request *, struct gotweb_url *, int *, > struct gotweb_url *, int *); > const struct got_error *gotweb_get_time_str(char **, time_t, int); > > -- Mark Jamsek <fnc.bsdbox.org> GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68
gotwebd: set filename for RSS feeds