Skip to content

Commit

Permalink
fix #783;
Browse files Browse the repository at this point in the history
Added 1.0 header for /Stream/ endpoint;
Bypassed the ASPNetCore ? error ?;
Endpoint working correct;
  • Loading branch information
bigretromike committed May 23, 2019
1 parent ecd87f7 commit 06490f4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Shoko.Server/API/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public string Read(HttpRequest request)
PathString[] apiv1 =
{
"/v1", "/api/Image", "/api/Kodi",
"/api/Metro", "/api/Plex"
"/api/Metro", "/api/Plex", "/Stream"
};

PathString[] apiv2 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,19 @@ private Stream StreamFromIFile(InfoResult r, bool? autowatch)
{
try
{
var request = HttpContext.Request;

string rangevalue = "";
// HttpContext is null and raise error
try
{
var request = HttpContext.Request;

This comment has been minimized.

Copy link
@bigretromike

bigretromike May 27, 2019

Author Contributor

@da3dsoul as HttpContext.Request is Null because of the ASPCore (bug, I read about that being null but it was supposed to be fix in 2.2 but I updated and it didn't helped and I didn't want to updated because something else could break) the byterange in not supported, so you cannot fast-seek file anymore.
It didn't work before, to fallback to working is ok, but without seek watching is not the same...

rangevalue = request.Headers["Range"].FirstOrDefault() ??
request.Headers["range"].FirstOrDefault();
}
catch
{

}

FileSystemResult<Stream> fr = r.File.OpenRead();
if (fr == null || !fr.IsOk)
{
Expand All @@ -137,8 +148,6 @@ private Stream StreamFromIFile(InfoResult r, bool? autowatch)
long start = 0;
long end = totalsize - 1;

string rangevalue = request.Headers["Range"].FirstOrDefault() ??
request.Headers["range"].FirstOrDefault();
rangevalue = rangevalue?.Replace("bytes=", string.Empty);
bool range = !string.IsNullOrEmpty(rangevalue);

Expand Down

7 comments on commit 06490f4

@da3dsoul
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No seeking is not okay. I'll write my own if needed

@da3dsoul
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did for Nancy, after all

@Cazzar
Copy link
Member

@Cazzar Cazzar commented on 06490f4 May 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HttpContext should also never be null in a HTTP request

@bigretromike
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a bug in ASPNetCore that would make HttpContext null;
But simple update of components didn't helped enough.

Can't tell if this is the same issue or not.

@bigretromike
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dotnet/aspnetcore#7975
But probably its not about this... don't know not into aspnetcore that much.

@Cazzar
Copy link
Member

@Cazzar Cazzar commented on 06490f4 May 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bigretromike That wouldn't relate to the issue, since we are using .net 4.7 and that explicitly state's .net core 2.2.2

@bigretromike
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought so, also when I updated all ASPNET related libraries (there's like 61 to update for Shoko Project) for testing it didn't solved the issue, so I didn't pushed it because knowing it there would be more harm than profit.

This issue was more than I could chew, so I fallback it so it would stream files, with our without ranges.

Please sign in to comment.