Skip to content

Validate remote script MIME type early #568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 10, 2020

Conversation

atifaziz
Copy link
Contributor

@atifaziz atifaziz commented Aug 6, 2020

This PR makes a small change that will make sure that the MIME type of the URL will be validated as soon as the HTTP headers are available and before the content is touched.

Suppose by a copy-paste error, the user supplies the URL of the wrong resource that's very large (taking the example of .NET Core 3.1 Runtime for Windows x64). Before this PR, it takes substantial time (shy of a minute on my good bandwidth) before the media type error is reported:

❯ Measure-Command { dotnet src\Dotnet.Script\bin\Release\netcoreapp3.1\dotnet-script.dll https://download.visualstudio.microsoft.com/download/pr/518aafee-1285-4153-a30a-e4eefd538c90/6437d77a67b9c6b8cf0b7b3323004229/dotnet-runtime-3.1.6-win-x64.exe }
The media type 'application/octet-stream' is not supported when executing a script over http/https

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 54
Milliseconds      : 787
Ticks             : 547878720
TotalDays         : 0.000634118888888889
TotalHours        : 0.0152188533333333
TotalMinutes      : 0.9131312
TotalSeconds      : 54.787872
TotalMilliseconds : 54787.872

After this PR, the error is reported in just over ½ of a second and no further bandwidth, time & memory (even money 😉) is wasted downloading the resource:

❯ Measure-Command { dotnet src\Dotnet.Script\bin\Release\netcoreapp3.1\dotnet-script.dll https://download.visualstudio.microsoft.com/download/pr/518aafee-1285-4153-a30a-e4eefd538c90/6437d77a67b9c6b8cf0b7b3323004229/dotnet-runtime-3.1.6-win-x64.exe }
The media type 'application/octet-stream' is not supported when executing a script over http/https

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 570
Ticks             : 5702311
TotalDays         : 6.59989699074074E-06
TotalHours        : 0.000158397527777778
TotalMinutes      : 0.00950385166666667
TotalSeconds      : 0.5702311
TotalMilliseconds : 570.2311

@atifaziz
Copy link
Contributor Author

atifaziz commented Aug 7, 2020

Can we relaunch the Mac build, which seems to have timed out after an hour?

@seesharper
Copy link
Collaborator

Started the build again

Copy link
Collaborator

@seesharper seesharper left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@seesharper seesharper requested a review from filipw August 7, 2020 19:53
@filipw filipw merged commit 9120d17 into dotnet-script:master Aug 10, 2020
@filipw
Copy link
Member

filipw commented Aug 10, 2020

thanks

@atifaziz atifaziz deleted the early-rs-validation branch August 10, 2020 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy