<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>MQX Software Solutions中的主题 MQX 4.1 HTTPSRV: How to modify the reponse header?</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-4-1-HTTPSRV-How-to-modify-the-reponse-header/m-p/384794#M12825</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm working on updating a project from MQX 3.8.1 to MQX 4.1.&amp;nbsp; The most major change is the new HTTPSRV API and the associated changes.&amp;nbsp; With the old HTTPD server I was able to modify the response header like so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14129739180711531 jive_text_macro jive_macro_code" jivemacro_uid="_14129739180711531" modifiedtitle="true"&gt;
&lt;P&gt;/* Send the reply */&lt;/P&gt;
&lt;P&gt;session-&amp;gt;response.contenttype = CONTENT_TYPE_HTML;&lt;/P&gt;
&lt;P&gt;session-&amp;gt;response.statuscode = 302;&lt;/P&gt;
&lt;P&gt;strncat(session-&amp;gt;response.header, "Location: control.html\n", HTTPDCFG_MAX_HEADER_LEN);&lt;/P&gt;
&lt;P&gt;httpd_sendhdr(session, 0, 0);&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can do the same with MQX 4.1?&amp;nbsp; session-&amp;gt;response no longer has a header field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Oct 2014 20:52:13 GMT</pubDate>
    <dc:creator>pbanta</dc:creator>
    <dc:date>2014-10-10T20:52:13Z</dc:date>
    <item>
      <title>MQX 4.1 HTTPSRV: How to modify the reponse header?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-4-1-HTTPSRV-How-to-modify-the-reponse-header/m-p/384794#M12825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm working on updating a project from MQX 3.8.1 to MQX 4.1.&amp;nbsp; The most major change is the new HTTPSRV API and the associated changes.&amp;nbsp; With the old HTTPD server I was able to modify the response header like so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14129739180711531 jive_text_macro jive_macro_code" jivemacro_uid="_14129739180711531" modifiedtitle="true"&gt;
&lt;P&gt;/* Send the reply */&lt;/P&gt;
&lt;P&gt;session-&amp;gt;response.contenttype = CONTENT_TYPE_HTML;&lt;/P&gt;
&lt;P&gt;session-&amp;gt;response.statuscode = 302;&lt;/P&gt;
&lt;P&gt;strncat(session-&amp;gt;response.header, "Location: control.html\n", HTTPDCFG_MAX_HEADER_LEN);&lt;/P&gt;
&lt;P&gt;httpd_sendhdr(session, 0, 0);&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can do the same with MQX 4.1?&amp;nbsp; session-&amp;gt;response no longer has a header field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Oct 2014 20:52:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-4-1-HTTPSRV-How-to-modify-the-reponse-header/m-p/384794#M12825</guid>
      <dc:creator>pbanta</dc:creator>
      <dc:date>2014-10-10T20:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: MQX 4.1 HTTPSRV: How to modify the reponse header?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-4-1-HTTPSRV-How-to-modify-the-reponse-header/m-p/384795#M12826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Paul,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it is no longer possible to modify a header of HTTP response directly. However in your case you can use a redirection in HTML using the &lt;EM&gt;http-equip&lt;/EM&gt; attribute of the &amp;lt;meta&amp;gt; tag (see &lt;A href="http://www.w3schools.com/tags/att_meta_http_equiv.asp" rel="nofollow noopener noreferrer" title="http://www.w3schools.com/tags/att_meta_http_equiv.asp" target="_blank"&gt;HTML meta http-equiv Attribute&lt;/A&gt;). And compose response using this tag in your CGI. Here is an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro _jivemacro_uid_14131909092901941 jive_macro_code" jivemacro_uid="_14131909092901941"&gt;
&lt;P&gt;response.content_type = HTTPSRV_CONTENT_TYPE_HTML;&lt;/P&gt;
&lt;P&gt;response.data = "&amp;lt;!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"&amp;gt;"&lt;/P&gt;
&lt;P&gt;"&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;My Title&amp;lt;/title&amp;gt;"&lt;/P&gt;
&lt;P&gt;"&amp;lt;meta http-equiv=\"REFRESH\" content=\"0;url=my_uri.html\"&amp;gt;&amp;lt;/head&amp;gt;\n&amp;lt;body&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;";&lt;/P&gt;
&lt;P&gt;response.data_length = strlen(response.data);&lt;/P&gt;
&lt;P&gt;response.content_length = 0;&lt;/P&gt;
&lt;P&gt;HTTPSRV_cgi_write(&amp;amp;response);&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit:&lt;/P&gt;&lt;P&gt;Regarding the content length: If it is set to zero, HTTP server will signalize end of response entity by closing the connection and thus ignoring keep-alive flag of session.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit2:&lt;/P&gt;&lt;P&gt;In MQX 4.2 there will be support for chunked transmission encoding so you will not have to worry about content length.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Karel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Oct 2014 08:44:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-4-1-HTTPSRV-How-to-modify-the-reponse-header/m-p/384795#M12826</guid>
      <dc:creator>karelm_</dc:creator>
      <dc:date>2014-10-13T08:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: MQX 4.1 HTTPSRV: How to modify the reponse header?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-4-1-HTTPSRV-How-to-modify-the-reponse-header/m-p/384796#M12827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Karel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the reply.&amp;nbsp; I'll give the http-equip attribute a try.&amp;nbsp; Looks like a good alternative as long as it works with IE, Firefox, Chrome, Safari.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Oct 2014 15:22:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-4-1-HTTPSRV-How-to-modify-the-reponse-header/m-p/384796#M12827</guid>
      <dc:creator>pbanta</dc:creator>
      <dc:date>2014-10-13T15:22:36Z</dc:date>
    </item>
  </channel>
</rss>

