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

Make Metadata use ContentType #5544

Merged
merged 3 commits into from Apr 14, 2015
Merged

Make Metadata use ContentType #5544

merged 3 commits into from Apr 14, 2015

Conversation

@boghison
Copy link
Contributor

boghison commented Apr 6, 2015

Fixes #5538

Review on Reviewable

@highfive
Copy link

highfive commented Apr 6, 2015

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @mbrubeck (or someone else) soon.

@hoppipolla-critic-bot
Copy link

hoppipolla-critic-bot commented Apr 6, 2015

Critic review: https://critic.hoppipolla.co.uk/r/4531

This is an external review system which you may optionally use for the code review of your pull request.

In order to help critic track your changes, please do not make in-place history rewrites (e.g. via git rebase -i or git commit --amend) when updating this pull request.

let page = format!("<html><body><img src='{}' /></body></html>", url.serialize());
parser.parse_chunk(page);
},
Some((ref t, ref st)) if t.as_slice().eq_ignore_ascii_case("text") &&
st.as_slice().eq_ignore_ascii_case("plain") => {
Some(ContentType(Mime(ref t, ref st, _))) if *t == TopLevel::Text &&

This comment has been minimized.

Copy link
@Manishearth

Manishearth Apr 6, 2015

Member

Can't we just do Mime(TopLevel::Text, SubLevel::Plain, _)?

This comment has been minimized.

Copy link
@boghison

boghison Apr 6, 2015

Author Contributor

Oh, yes, totally, I was just keeping the original structure :)

@@ -291,12 +293,12 @@ pub fn parse_html(document: JSRef<Document>,
}
HTMLInput::InputUrl(load_response) => {
match load_response.metadata.content_type {
Some((ref t, _)) if t.as_slice().eq_ignore_ascii_case("image") => {
Some(ContentType(Mime(ref t, _, _))) if *t == TopLevel::Image => {

This comment has been minimized.

Copy link
@Manishearth

Manishearth Apr 6, 2015

Member

(same here)

@@ -1067,8 +1069,8 @@ impl ScriptTask {
});

let content_type = match response.metadata.content_type {
Some((ref t, ref st)) if t.as_slice().eq_ignore_ascii_case("text") &&
st.as_slice().eq_ignore_ascii_case("plain") => {
Some(ContentType(Mime(ref t, ref st, _))) if *t == TopLevel::Text &&

This comment has been minimized.

Copy link
@Manishearth

Manishearth Apr 6, 2015

Member

(same here)

@Manishearth
Copy link
Member

Manishearth commented Apr 6, 2015

Looks good, aside from some minor fixes in the match.

Thanks!

@Manishearth
Copy link
Member

Manishearth commented Apr 6, 2015

@bors-servo
Copy link
Contributor

bors-servo commented Apr 6, 2015

📌 Commit 84e9b5d has been approved by Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented Apr 8, 2015

Testing commit 84e9b5d with merge 76ec67f...

bors-servo pushed a commit that referenced this pull request Apr 8, 2015
@bors-servo
Copy link
Contributor

bors-servo commented Apr 8, 2015

💔 Test failed - mac2

@jdm
Copy link
Member

jdm commented Apr 8, 2015

Sorry, looks like #5005 added some code that needs to be adjusted now.

/Users/servo/buildbot/slave/mac2/build/components/net/resource_task.rs:82:53: 82:75 error: mismatched types:
 expected `&core::option::Option<(collections::string::String, collections::string::String)>`,
    found `&core::option::Option<hyper::header::common::content_type::ContentType>`
(expected tuple,
    found struct `hyper::header::common::content_type::ContentType`) [E0308]
/Users/servo/buildbot/slave/mac2/build/components/net/resource_task.rs:82                                                     &metadata.content_type, &partial_body);
                                                                                                                              ^~~~~~~~~~~~~~~~~~~~~~
/Users/servo/buildbot/slave/mac2/build/components/net/resource_task.rs:81:33: 82:91 error: mismatched types:
 expected `core::option::Option<hyper::header::common::content_type::ContentType>`,
    found `core::option::Option<(collections::string::String, collections::string::String)>`
(expected struct `hyper::header::common::content_type::ContentType`,
    found tuple) [E0308]
/Users/servo/buildbot/slave/mac2/build/components/net/resource_task.rs:81         metadata.content_type = classifier.classify(nosniff, check_for_apache_bug,
/Users/servo/buildbot/slave/mac2/build/components/net/resource_task.rs:82                                                     &metadata.content_type, &partial_body);
error: aborting due to 2 previous errors
@boghison
Copy link
Contributor Author

boghison commented Apr 8, 2015

@jdm so what am I supposed to do, edit the whole mime classifier or just send toplevel and sublevel as strings?

@jdm
Copy link
Member

jdm commented Apr 8, 2015

I would go ahead and edit the classifier code.

@boghison
Copy link
Contributor Author

boghison commented Apr 8, 2015

@jdm That is going to need a lot of rewriting, mostly because almost everything has been fixed to use strings there

@jdm
Copy link
Member

jdm commented Apr 8, 2015

Oh, hmm. Go ahead and pass it strings, in that case. We can file a follow-up to rewrite it separately.

@boghison
Copy link
Contributor Author

boghison commented Apr 8, 2015

@jdm Yes, that would be best, the hardest part is probably dealing with non standard types like application+xml

@boghison
Copy link
Contributor Author

boghison commented Apr 9, 2015

@jdm How do I actually convert a mime to a string?

@jdm
Copy link
Member

jdm commented Apr 9, 2015

You might need to resort to format!("{}", mime) for the full a/b format, or format!("{}", mime.0) for the subparts in particular.

@jdm
Copy link
Member

jdm commented Apr 14, 2015

@bors-servo
Copy link
Contributor

bors-servo commented Apr 14, 2015

📌 Commit 214c9d9 has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Apr 14, 2015

Testing commit 214c9d9 with merge 55d19d1...

bors-servo pushed a commit that referenced this pull request Apr 14, 2015
Fixes #5538

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5544)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Apr 14, 2015

💔 Test failed - linux1

@jdm
Copy link
Member

jdm commented Apr 14, 2015

<std macros>:5:10: 5:35 error: the trait `core::cmp::PartialEq<core::option::Option<(collections::string::String, collections::string::String)>>` is not implemented for the type `core::option::Option<hyper::header::common::content_type::ContentType>` [E0277]
<std macros>:5 if ! ( ( * left_val == * right_val ) && ( * right_val == * left_val ) ) {
                        ^~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 9:39 note: in expansion of assert_eq!
/home/servo/buildbot/slave/linux1/build/tests/unit/net/data_loader.rs:21:5: 21:64 note: expansion site
<std macros>:5:43: 5:68 error: the trait `core::cmp::PartialEq<core::option::Option<hyper::header::common::content_type::ContentType>>` is not implemented for the type `core::option::Option<(collections::string::String, collections::string::String)>` [E0277]
<std macros>:5 if ! ( ( * left_val == * right_val ) && ( * right_val == * left_val ) ) {
                                                         ^~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 9:39 note: in expansion of assert_eq!
/home/servo/buildbot/slave/linux1/build/tests/unit/net/data_loader.rs:21:5: 21:64 note: expansion site

You can reproduce this with ./mach test-unit.

@jdm jdm added S-tests-failed and removed S-awaiting-merge labels Apr 14, 2015
@boghison
Copy link
Contributor Author

boghison commented Apr 14, 2015

@jdm To fix this test I'd have to add hyper as an external dependency, is it ok?

@Manishearth
Copy link
Member

Manishearth commented Apr 14, 2015

Yes, to the unit tests crate.

@boghison
Copy link
Contributor Author

boghison commented Apr 14, 2015

@Manishearth Yes, obviously

@jdm
Copy link
Member

jdm commented Apr 14, 2015

@bors-servo
Copy link
Contributor

bors-servo commented Apr 14, 2015

📌 Commit 3dd48d2 has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Apr 14, 2015

Testing commit 3dd48d2 with merge 7f422e2...

bors-servo pushed a commit that referenced this pull request Apr 14, 2015
bors-servo
Fixes #5538

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5544)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Apr 14, 2015

☀️ Test successful - android, gonk, linux1, linux2, mac1, mac2

@bors-servo bors-servo merged commit 3dd48d2 into servo:master Apr 14, 2015
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

6 participants
You can’t perform that action at this time.