Skip to content
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

Implement MIME sniffing #3144

Closed
Manishearth opened this issue Aug 25, 2014 · 7 comments
Closed

Implement MIME sniffing #3144

Manishearth opened this issue Aug 25, 2014 · 7 comments

Comments

@Manishearth
Copy link
Member

@Manishearth Manishearth commented Aug 25, 2014

We should be able to sniff the MIME type for file:/// URLs and perhaps pages that do not provide a Content-Type header.

The specification for guessing MIME types is here.

This would benefit #3131 too.

@jdm
Copy link
Member

@jdm jdm commented Sep 12, 2014

This may be worked on by NCSU students; any other interested parties please contact me before attempting to start this work.

@jdm
Copy link
Member

@jdm jdm commented Sep 12, 2014

Background information: When an HTTP resource declares the type of its content (using the Content-Type header), it's very easy to decide how to present it - if it's an image, decode it; if it's an HTML page, parse and display it. When no such header is present, Servo currently falters (such as loading an image file from disk, as in #3131). We want to implement the "sniffing" specification, which looks at the starting byte content of the resource and guesses what manner of content is being received.

Initial step: Build Servo. Learn about tasks in Rust, then spawn a new sniffer task in the load method in resource_task.rs, creating a sender and receiver pair as well - the task should read all available data from the new receiver, and send it immediately via the original sender, while the new sender gets handed off to the factory function that is executed. All web pages should continue to load unchanged after rebuilding.

Steps:

  • interpose a sniffer in every resource request in the load method in resouce_task.rs - make a new sender/receiver pair, spawn a task that waits for input on the new receiver and passes it on to the old sender, while handing off the new sender to the factory function
  • move from a 1:1 sniffer:request task model to a shared sniffer task - create the sniffing task in ResourceTask::start, store the created sender in a field, and hand off clones of this sender to the factory function. The sniffer task will now also have to be sent the original sender as well, since it is not available at task creation.
  • when the headers are received, implement the sniffing heuristic algorithm
  • implement the mime type matching algorithm, one category at a time - look for a good way to store the patterns and resulting types to minimize code duplication
  • ensure that the resulting mime type is present in the load that the consumer receives
  • write tests that demonstrate working sniffing (for example, loading images with no/wrong extension)
@BrendanEich
Copy link

@BrendanEich BrendanEich commented Sep 13, 2014

Are tasks cheap enough? Rust economics have shifted enough since the lots-of-tasks-in-Servo era that I wonder. Sorry if this is off-target as a drive-by question.

/be

@jdm
Copy link
Member

@jdm jdm commented Sep 13, 2014

Tasks are the easiest mechanism at this point. It's not a big deal to fix up later, and it sounds like we may be bringing back green tasks for Servo in the future.

@Kavit900
Copy link

@Kavit900 Kavit900 commented Sep 28, 2014

Hello Jon Sir, my name is Kavit and I am an NCSU student, I got this topic as my OSS project and I would like to know more about it...

@jdm
Copy link
Member

@jdm jdm commented Sep 28, 2014

@Kavit900 Are you one of Kshitij, David, or Vineela? In any case, could you be more specific about what information you're looking for?

@Kavit900
Copy link

@Kavit900 Kavit900 commented Sep 28, 2014

jdm, I am not one of them , I am still in waitlist for this project , so as soon as it gets confirmed I will contact you. Thank you for your early reply....

bors-servo pushed a commit that referenced this issue Nov 14, 2014
Issue: #3144 

We created a sniffer task in components/net/, added a call in resource_task load function to create a new sniffer task (sending all the data), and sniffer_task currently sends all the data back to resource_task.

The purpose of this request is to get feedback from @jdm on our progress before moving forward and writing tests.
bors-servo pushed a commit that referenced this issue Nov 14, 2014
Issue: #3144 

We created a sniffer task in components/net/, added a call in resource_task load function to create a new sniffer task (sending all the data), and sniffer_task currently sends all the data back to resource_task.

The purpose of this request is to get feedback from @jdm on our progress before moving forward and writing tests.
bors-servo pushed a commit that referenced this issue Nov 15, 2014
Issue: #3144 

We created a sniffer task in components/net/, added a call in resource_task load function to create a new sniffer task (sending all the data), and sniffer_task currently sends all the data back to resource_task.

The purpose of this request is to get feedback from @jdm on our progress before moving forward and writing tests.
bors-servo pushed a commit that referenced this issue Nov 15, 2014
Issue: #3144 

We created a sniffer task in components/net/, added a call in resource_task load function to create a new sniffer task (sending all the data), and sniffer_task currently sends all the data back to resource_task.

The purpose of this request is to get feedback from @jdm on our progress before moving forward and writing tests.
bors-servo pushed a commit that referenced this issue Nov 15, 2014
Issue: #3144 

We created a sniffer task in components/net/, added a call in resource_task load function to create a new sniffer task (sending all the data), and sniffer_task currently sends all the data back to resource_task.

The purpose of this request is to get feedback from @jdm on our progress before moving forward and writing tests.
@jdm jdm added the C-assigned label Nov 27, 2014
bors-servo pushed a commit that referenced this issue Nov 27, 2014
Issue: #3144

This PR addresses the second step of the ticket. i.e. move from a 1:1 sniffer:request task model to a shared sniffer task.
bors-servo pushed a commit that referenced this issue Nov 28, 2014
Issue: #3144

This PR addresses the second step of the ticket. i.e. move from a 1:1 sniffer:request task model to a shared sniffer task.
@jdm jdm closed this Aug 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.