Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How to set mime-type in JApplicationWeb
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  18 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Andreas Tasch  
View profile  
 More options May 25 2012, 3:31 am
From: Andreas Tasch <andy.ta...@gmail.com>
Date: Fri, 25 May 2012 00:31:30 -0700 (PDT)
Local: Fri, May 25 2012 3:31 am
Subject: How to set mime-type in JApplicationWeb

Hi,

what is the correct platform way to set the header information. Inside my
JApplicationWeb app i want to set the mime type to something other than
'text/xml'.

I tried JDocument, JResponse and $this->setHeader nothing works. Only if I
do a $this->mimeType('my-mime-type'); But I assume manipulating a class var
directly instead setter method is not the way to go and may brake in future.

Here you can see an example:
http://pastebin.com/VWJEJwgd

Thanks,
ndee


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andreas Tasch  
View profile  
 More options May 25 2012, 3:55 am
From: Andreas Tasch <andy.ta...@gmail.com>
Date: Fri, 25 May 2012 00:55:31 -0700 (PDT)
Local: Fri, May 25 2012 3:55 am
Subject: Re: How to set mime-type in JApplicationWeb

This line seems to overwrite the header set by $this->setHeader() with the
initial "text/html" value?
https://github.com/joomla/joomla-platform/blob/staging/libraries/joom...

Am Freitag, 25. Mai 2012 09:31:30 UTC+2 schrieb Andreas Tasch:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Babker  
View profile  
 More options May 25 2012, 4:49 am
From: Michael Babker <mbab...@flbab.com>
Date: Fri, 25 May 2012 10:49:38 +0200
Local: Fri, May 25 2012 4:49 am
Subject: Re: [jplatform] Re: How to set mime-type in JApplicationWeb

Since $this->mimeType is a public variable, you should be free to set that
to what you need it to be.  When the response is sent in that method, that's
when the headers are built it looks like.

From:  Andreas Tasch <andy.ta...@gmail.com>
Reply-To:  <joomla-dev-platform@googlegroups.com>
Date:  Friday, May 25, 2012 9:55 AM
To:  <joomla-dev-platform@googlegroups.com>
Subject:  [jplatform] Re: How to set mime-type in JApplicationWeb

This line seems to overwrite the header set by $this->setHeader() with the
initial "text/html" value?
https://github.com/joomla/joomla-platform/blob/staging/libraries/joom...
ication/web.php#L417

Am Freitag, 25. Mai 2012 09:31:30 UTC+2 schrieb Andreas Tasch:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Will Daniels  
View profile   Translate to Translated (View Original)
 More options May 25 2012, 8:15 am
From: Will Daniels <m...@willdaniels.co.uk>
Date: Fri, 25 May 2012 13:15:43 +0100
Local: Fri, May 25 2012 8:15 am
Subject: Re: [jplatform] Re: How to set mime-type in JApplicationWeb

I have always used JDocument::setMimeEncoding [1]

But strictly speaking, that is a misnomer because it's actually setting the
Content-Type header not the Content-Transfer-Encoding header as implied by
"encoding". It should be setMimeType.

-Will

https://github.com/joomla/joomla-platform/blob/staging/libraries/joom...

On 25/05/12 09:49, Michael Babker wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Will Daniels  
View profile   Translate to Translated (View Original)
 More options May 25 2012, 8:24 am
From: Will Daniels <m...@willdaniels.co.uk>
Date: Fri, 25 May 2012 13:24:41 +0100
Local: Fri, May 25 2012 8:24 am
Subject: Re: [jplatform] Re: How to set mime-type in JApplicationWeb

Example usage in an old CMS system plugin of mine:

https://github.com/wdaniels/joomla-xhtml-headers/blob/master/xhtml.php

I assume things work much the same still, though I haven't had time to play
around making any apps using just the Platform yet.

Hope this helps.

-Will

On 25/05/12 13:15, Will Daniels wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andreas Tasch  
View profile   Translate to Translated (View Original)
 More options May 28 2012, 5:21 am
From: Andreas Tasch <andy.ta...@gmail.com>
Date: Mon, 28 May 2012 11:21:37 +0200
Local: Mon, May 28 2012 5:21 am
Subject: Re: [jplatform] Re: How to set mime-type in JApplicationWeb

Hi Will and Michael,

thank you for your help.

Will in your plugin you use JDocument->setMimeType() to set the mime-type.
As you can see on my pastebin example above, I tried that too. JDocument
sets the header properly but on output JApplicationWeb seems to ignore it
and uses instead only the JApplicationWeb->mimeType variable.

Even if I try to set the header with JApplicationWeb->setHeaders() they get
actually set but the mime-type is ignored and replaced/overwritten by the
JApplicationWeb->mimeType variable.

Short, neither JDocument nor JApplicationWeb->setHeaders() are able to set
the mime-type because only the public var JApplicationWeb->mimeType is
taken into account.

Here the above pastebin example with some testoutput. Just run the file and
you will see that $this->setHeaders() and $document->setMimeEncoding() have
NO effect on the mime-type output. Only if you uncomment the direct change
of $this->mimeType you will get the correct mime-type.
http://pastebin.com/CQPqx2eV

My question is, do I miss something or why do setHeaders() or
$doc->setMimeType not get recognized or taken into account by
JApplicationWeb?

Please take also a look in second post mentioned line, where
JApplicationWeb renders the document and gets the mime-type directly from
its mimeType variable and does not check JDocument or its own headers if
the mime-type got set.
https://github.com/joomla/joomla-platform/blob/staging/libraries/joom...
Do you guys think this is a bug or expected behaviour?

Thanks!

2012/5/25 Will Daniels <m...@willdaniels.co.uk>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Elin Waring  
View profile   Translate to Translated (View Original)
 More options May 29 2012, 8:43 pm
From: Elin Waring <elin.war...@gmail.com>
Date: Tue, 29 May 2012 17:43:34 -0700 (PDT)
Local: Tues, May 29 2012 8:43 pm
Subject: Re: How to set mime-type in JApplicationWeb

It looks to me like that line is missing the replacement flag so it is
defaulting to false and not replacing.
https://github.com/joomla/joomla-platform/blob/staging/libraries/joom...

Elin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andreas Tasch  
View profile   Translate to Translated (View Original)
 More options May 30 2012, 1:58 am
From: Andreas Tasch <andy.ta...@gmail.com>
Date: Wed, 30 May 2012 07:58:17 +0200
Local: Wed, May 30 2012 1:58 am
Subject: Re: [jplatform] Re: How to set mime-type in JApplicationWeb

Hi Elin,

please take a look at my example, line 45:
http://pastebin.com/CQPqx2eV

I used the override switch, or did I miss something, or am I using it the
wrong way?

As mentioned I think the problem is that the values set by setHeader() are
set but not taken into account in response() function. That's why I
mentioned line 417 in JApplicationWeb:
https://github.com/joomla/joomla-platform/blob/staging/libraries/joom...
(other headers are handled correctly but mime-type is set by class variable
mimeType, and mime-type set by setHeaders() is not taken into account?)

2012/5/30 Elin Waring <elin.war...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Elin Waring  
View profile   Translate to Translated (View Original)
 More options May 30 2012, 8:01 am
From: Elin Waring <elin.war...@gmail.com>
Date: Wed, 30 May 2012 08:01:03 -0400
Local: Wed, May 30 2012 8:01 am
Subject: Re: [jplatform] Re: How to set mime-type in JApplicationWeb

I know you are using the flag, what I'm questioning is why 417 doesn't use
the replacement flag which in the case of mime type perhaps should default
to true.

Elin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andreas Tasch  
View profile  
 More options May 30 2012, 6:58 pm
From: Andreas Tasch <andy.ta...@gmail.com>
Date: Thu, 31 May 2012 00:58:52 +0200
Local: Wed, May 30 2012 6:58 pm
Subject: Re: [jplatform] Re: How to set mime-type in JApplicationWeb

Hi Elin,

sorry my fault. The flag is imho working but the problem is that
$this->mimeType is used as content-type no matter what is set by setHeaders
(see line 417 in JApplicationWeb). Imo the problem is that setHeaders()
does not update $this->mimeType. So a possible solution is to add a few
lines of code to setHeaders() to update mimeType variable:
https://github.com/ndeet/joomla-platform/commit/f3c53e719cd7bab8657ca...

However, JDocument->setMimeType() is still not working, have to figure that
one out too. Seems that it is passed to JResponse - dunno but JResponse is
not overwriting the header output.

2012/5/30 Elin Waring <elin.war...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andreas Tasch  
View profile  
 More options Jun 13 2012, 4:58 am
From: Andreas Tasch <andy.ta...@gmail.com>
Date: Wed, 13 Jun 2012 01:58:17 -0700 (PDT)
Local: Wed, Jun 13 2012 4:58 am
Subject: Re: How to set mime-type in JApplicationWeb

Hi anybody,

please let me know if my proposed patch fixes the problem and I should open
a tracker item on github or make a pull request on this issue. Here is my
suggestion:
https://github.com/ndeet/joomla-platform/commit/f3c53e719cd7bab8657ca...

The JDocument issue is not yet resolved as I had no time yet too look
deeper into the issue. In general terms, shouldn't
JDocument::setMimeEncoding etc. delegate the header stuff to
JApplicationWeb? Is there a good reason that JDocument and JApplicationWeb
does the same thing differently?

Am Freitag, 25. Mai 2012 09:31:30 UTC+2 schrieb Andreas Tasch:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Moffatt  
View profile  
 More options Jun 13 2012, 12:03 pm
From: Sam Moffatt <pasa...@gmail.com>
Date: Wed, 13 Jun 2012 09:03:05 -0700
Local: Wed, Jun 13 2012 12:03 pm
Subject: Re: [jplatform] Re: How to set mime-type in JApplicationWeb
JApplicationWeb is a new class which is a mix of various previous
classes and a re-think about how a Joomla! web application works.
JDocument is a much older class (easily coming up on it's 5th
birthday) and was designed with the legacy JApplication class.

Cheers,

Sam Moffatt
http://pasamio.id.au


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andreas Tasch  
View profile  
 More options Jun 13 2012, 6:33 pm
From: Andreas Tasch <andy.ta...@gmail.com>
Date: Thu, 14 Jun 2012 00:33:47 +0200
Local: Wed, Jun 13 2012 6:33 pm
Subject: Re: [jplatform] Re: How to set mime-type in JApplicationWeb

Hi Sam,

thanks for clarification. So, the JDocument->setMimeEncoding() should
actually work and change the mime type output. But on my previous code
snipped I was not able to do that. Therefore I started this thread.
First, the new (JApplicationWeb) way is to use class variable mimeType or
the function setHeaders() - the latter does not seem to work therefore my
try to fix it and the question if anybody can confirm this as bug.
Second, JDocument->setMimeEncoding() does not work either or I use it the
wrong way (see code snipped). Would be great if anybody can confirm if this
is also a bug (then I can see if I can fix it) or show me the right way to
use it (in case I use it the wrong way).

Thanks.

2012/6/13 Sam Moffatt <pasa...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Elin Waring  
View profile  
 More options Jun 14 2012, 7:49 am
From: Elin Waring <elin.war...@gmail.com>
Date: Thu, 14 Jun 2012 04:49:08 -0700 (PDT)
Local: Thurs, Jun 14 2012 7:49 am
Subject: Re: How to set mime-type in JApplicationWeb

I was going to say that you should write a test for the bug but respond()
is one of the small number of places in JApplicationWeb that doesn't have
any test at all so you would need to write the whole thing. But setHeader
is covered and that's where you are proposing code ... so if you wrote a
test specific test for mime/type and that failed we would definitely know
there is a problem there.  I would think it would be better to actually fix
the problem with setHeader if there is one than to write in such a specific
work around. Why would it be that setHeader works for everything but
mime/type? ... it seems a bit odd but there have been much stranger things.

Elin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Moffatt  
View profile  
 More options Jun 14 2012, 10:47 pm
From: Sam Moffatt <pasa...@gmail.com>
Date: Thu, 14 Jun 2012 19:47:42 -0700
Local: Thurs, Jun 14 2012 10:47 pm
Subject: Re: [jplatform] Re: How to set mime-type in JApplicationWeb
No, I don't think JDocument::setMimeEncoding() should likely work with
the new classes as it was built for a differently structured class and
application configuration (the JResponse class). It should likely
continue to do this at least in the short term otherwise the CMS will
break. As I noted, JDocument was built for a different version of
JApplication. JDocument's future is an interesting question however I
really don't think it's use coupled with the new JApplicationWeb class
is intended or advised (though obviously not impossible, there is just
an overlap between what it expects and reality for your new
application).

JApplicationWeb::setHeaders() is working though I think if you look
carefully you will find that effectively what you're instructing the
app to do is send two content type headers. PHP if it isn't passing
that along will be picking one of them and sending it. The intended
behaviour is that you set the variable in the application and it is
handled for you.

Cheers,

Sam Moffatt
http://pasamio.id.au


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Amy Stephen  
View profile  
 More options Jun 15 2012, 12:23 am
From: Amy Stephen <amystep...@gmail.com>
Date: Thu, 14 Jun 2012 23:23:27 -0500
Local: Fri, Jun 15 2012 12:23 am
Subject: Re: [jplatform] Re: How to set mime-type in JApplicationWeb

On Thu, Jun 14, 2012 at 9:47 PM, Sam Moffatt <pasa...@gmail.com> wrote:
> JDocument's future is an interesting question however I
> really don't think it's use coupled with the new JApplicationWeb class
> is intended or advised (though obviously not impossible, there is just
> an overlap between what it expects and reality for your new
> application).

But, JDocument is coupled with JApplicationWeb. ?

https://github.com/joomla/joomla-platform/commit/b73345998452b8aebc05...

> The intended
> behaviour is that you set the variable in the application and it is
> handled for you.

That's all I hear him asking -- was that the intention, or are the
getter/setters accidentally missing (and therefore, he found a bug)?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Moffatt  
View profile  
 More options Jun 15 2012, 12:40 am
From: Sam Moffatt <pasa...@gmail.com>
Date: Thu, 14 Jun 2012 21:40:49 -0700
Local: Fri, Jun 15 2012 12:40 am
Subject: Re: [jplatform] Re: How to set mime-type in JApplicationWeb

On Thu, Jun 14, 2012 at 9:23 PM, Amy Stephen <amystep...@gmail.com> wrote:
>> JDocument's future is an interesting question however I
>> really don't think it's use coupled with the new JApplicationWeb class
>> is intended or advised (though obviously not impossible, there is just
>> an overlap between what it expects and reality for your new
>> application).

> But, JDocument is coupled with JApplicationWeb. ?

You can use it, I just don't feel it's advised. As noted there is an
overlap and there are things JDocument does that JApplicationWeb
doesn't and don't exist elsewhere. As I noted, it's an interesting
question where we take this because having two classes doing similar
things causes confusion hence this discussion.

>> The intended
>> behaviour is that you set the variable in the application and it is
>> handled for you.

> That's all I hear him asking -- was that the intention, or are the
> getter/setters accidentally missing (and therefore, he found a bug)?

It's a public variable. Why do you need getters and setters for a
public variable? And is the statement somehow unclear? I'm confused!

Cheers,

Sam Moffatt
http://pasamio.id.au


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andreas Tasch  
View profile  
 More options Jun 15 2012, 3:28 am
From: Andreas Tasch <andy.ta...@gmail.com>
Date: Fri, 15 Jun 2012 09:28:27 +0200
Local: Fri, Jun 15 2012 3:28 am
Subject: Re: [jplatform] Re: How to set mime-type in JApplicationWeb

Hi thanks for your answers and clarification!

Regarding $mimeType as public var. It is ok, I just have the impression
that in changing a public var does not feel right. Imho content-type is
releated to PHP's header() function (see
http://www.php.net/manual/en/function.header.php). Therefore my impression
is that setHeader() should handle it. Maybe I'm wrong and
content-type/mime-type is not related to http-headers? - would be great to
hear your views on this.

JDocument. Does not the CMS rely heavily rely on JDocument? All code
examples I found in manipulating the header (prior to joomla-platform
birth) is related to JDocument. So if extensions or even the CMS use
JDocument to set mime-type it will not work anymore? What about
view.xml.php views will it fail (unfortunately I had no time left yet to
check this more deeply). Is there a b/c issue if JDocument is not able to
overwrite the headers (or maybe it should be refactored to use
JApplicationWeb->setHeader()?

Thank you all for participating.

2012/6/15 Sam Moffatt <pasa...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »