eclipse-archived / californium.core

Californium project
86 stars 69 forks source link

Compare mime types directly in HttpTranslator #32

Closed plemarquand closed 9 years ago

plemarquand commented 9 years ago

When translating HTTP requests in the proxy, if the contentType was created via ContentType.parse the charset of the translated request would always be modified to be ISO_8859_1 even if the content type was application/json. The newly created content type was compared to the existing static instance using object equality instead of .equals().

Fixes the issue by comparing mime types directly.

sophokles73 commented 9 years ago

Glad it worked, Paul. Could you also provide a unit test for this?

plemarquand commented 9 years ago

@sophokles73 I can't find any existing tests for californium-proxy. Should I create a test/ directory under the californium-proxy project or are there functional tests somewhere I'm not seeing?

sophokles73 commented 9 years ago

Seems like you have found the heel of Achilles of Californium Proxy ;-) We are always lacking unit tests, so feel free to add the corresponding folder and create the first test case :-)

plemarquand commented 9 years ago

@sophokles73 The new patch in the request adds 2 tests that validate the original patch. Luckily Maven was already configured to run tests in the project so it was more straightforward than I thought it'd be.

sophokles73 commented 9 years ago

@plemarquand,

the test case currently lacks the eclipse copyright header. Simply copy the header from another file and make sure to update the copyright year to include 2015 and add your name along with a little comment what you fixed at the bottom of the header.

plemarquand commented 9 years ago

@sophokles73 Eclipse header added, I've amended the commit.

plemarquand commented 9 years ago

@sophokles73 Addressed newline comment

plemarquand commented 9 years ago

@sophokles73 Additional patch cleans up the commented code and adds me as a contributor to the file.

sophokles73 commented 9 years ago

Thanks @plemarquand :-)

I have squashed all three commits into one and merged to master ...

plemarquand commented 9 years ago

@sophokles73 Thanks!

sophokles73 commented 9 years ago

My pleasure! Hope we'll see some more patches/contributions from you .. :-)