FIle downloading using HTTP - xmpp

I am having trouble finding the correct XEP to use for this specific use case:
Initiator (e.g. iOS or Android device) uploads a file to a server and needs to notify the responder (in this case this would be a browser based client) to download the file from the location he just uploaded to using HTTP.
All the XEP's I have come across talk about streams or IBB/SOCKS5. I did found the following which could be useful but no updates since 2007:
http://xmpp.org/extensions/inbox/jingle-httpft.html
Am I overlooking something on an XEP which is in draft or final?

Either use XEP-0066: Out of Band Data, or just encode the link in a XEP-0071: XHTML-IM a element.
The first:
<message from='stpeter#jabber.org/work'
to='MaineBoy#jabber.org/home'>
<body>Yeah, but do you have a license to Jabber?</body>
<x xmlns='jabber:x:oob'>
<url>http://www.jabber.org/images/psa-license.jpg</url>
</x>
</message>
The second:
<message>
<body>here is a file [http://www.jabber.org/images/psa-license.jpg]</body>
<html xmlns='http://jabber.org/protocol/xhtml-im'>
<body xmlns='http://www.w3.org/1999/xhtml'>
<p>Here is a <a href='http://www.jabber.org/images/psa-license.jpg'>file</a></p>
</body>
</html>
</message>

Related

Mailchimp No Host Exception when Subscribing Email to A List

I'm trying to send a subscription call, but got an error saying the the URL is invalid.
This is the URL I used:
https://us14.api.mailchimp.com/3.0/lists/<list-id>/members/
then I get this back in the response:
<HTML>
<HEAD>
<TITLE>Invalid URL</TITLE>
</HEAD>
<BODY>
<H1>Invalid URL</H1>
The requested URL "http://%5bNo%20Host%5d/3.0/lists/41e44e1bde/members/", is invalid.
<p>
Reference #9.cc6a1db8.1483891456.16189371
</BODY>
</HTML>
which translates to:
http://[No Host]/3.0/lists/<list-id>/members/
us14 is definitely the right data center according to the documentation so I'm not quite sure what's wrong.
It turned out that if you set HTTP header field "Host" in the request, it will always return this error. I tested this out by removing every fields one-by-one and this was the only one that caused an issue.
Many environments use the Host header for stuff like virtual sites where you are running more than one website behind the same IP Address (i.e. api.mailchimp.com and www.mailchimp.com could be on the same server) It is definitly possible for an error to be received if you set an invalid host since their proxies can't route it correctly. Normally, the host header is set automatically by the browser or HTTP client and usually not something you would override.
Are you still having trouble? If so, would be useful to see a screenshot of something like PostMan or https://ApiRequest.IO to see what your inputs are.

Zephyr API to access test steps not working

I need to access test steps of a test case.
When I tried the following URL using CURL GET request,
http:///rest/zapi/latest/teststep//
I am getting the following error message
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved here.</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at <jira_server> Port 80</address>
</body></html>
Same request using the browser gives {}
I got the issue ID using the REST API
"https:///rest/api/2/issue/testCaseId
So I am sure that the issue Id is correct.
Is this something because of latest zephyr update?
Can some one help me what is the issue with the request?
Unfortunately I think you have to purchase a plugin to use the ZAPI:
https://marketplace.atlassian.com/plugins/com.thed.zephyr.zapi
You can, however, connect to your database yourself and try to extract the test steps by looking for a table called [SOME_PREFIX_SUCH_AS_A7AEFBD]_TESTSTEP in your jira database. It holds an ID for the issue it belongs to so combining it with the jiraissues table you can fetch all test steps for a test issue you've made. Put that query result into an excel sheet and you have yourself a cheap extraction of your test steps.

Does Google Talk accept HTML formatted chats?

I have sent Google Talk chats that are HTML in the way described by this question: How do you send HTML formatted messages over XMPP with Node.JS?
However, Gtalk seems to just interpret it as text. Does Gtalk accept HTML formatted messages?
To respond to the comment below: it could be either the client or the server that Google runs which is interpreting it incorrectly.
Yes, Google Talk accepts HTML formatted messages. However, as you observed, it disregards the formatted text and only shows the plain text. According to the XHTML-IM XEP, every HTML message must be accompanied by a plain text message for compatibility with clients that do not support HTML formatted messages.
When I send this example message to the Google Talk client on my Windows machine (using Psi's XML input console)...
<message to="test#gmail.com/Talk.v10445D0E8B1">
<body>Wow, I&apos;m green with envy!</body>
<html xmlns='http://jabber.org/protocol/xhtml-im'>
<body xmlns='http://www.w3.org/1999/xhtml'>
<p style='font-size:large'>
<em>Wow</em>, I&apos;m <span style='color:green'>green</span>
with <strong>envy</strong>!
</p>
</body>
</html>
</message>
... I just see the text Wow, I'm green with envy!.
When I send the same message to my Psi client logged in to Google Talk, I receive...
<message from="test#jabber.org/Ben-PC" to="test#gmail.com">
<body>Wow, I'm green with envy!</body>
<html xmlns="http://jabber.org/protocol/xhtml-im">
<body xmlns="http://www.w3.org/1999/xhtml">
<p style="font-size:large">
<em>Wow</em>, I'm <span style="color:green">green</span>
with <strong>envy</strong>!
</p>
</body>
</html>
</message>
It was not stripped from the HTML, exactly as I expected (servers should not change the contents of messages). It shows as , so it looks like Psi does support formatted text.
The way to test for capabilities is using Service Discovery. If I send...
<iq to='test#gmail.com/Talk.v10445D0E8B1' type='get'>
<query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
... I receive...
<iq from="test#gmail.com/Talk.v10445D0E8B1" type="error" to="test#jabber.org/Ben-PC">
<query xmlns="http://jabber.org/protocol/disco#info"/>
<error type="cancel" code="501">
<feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
</error>
</iq>
... which means the Google Talk client does not support Service Discovery. We have to rely on the observation that HTML message text is ignored by the Google Talk client and server.

cflocation vs cfheader for 301 redirects

I am "renaming" an existing file for a project I am working on. To maintain backwards compatibility, I am leaving a cfm file in place to redirect the users to the new one.
buy.cfm: old
shop.cfm: new
In order to keep everything as clean as possible, I want to send the 301 statuscode response if a user tries to go to buy.cfm.
I know that I can use either cflocation with the statuscode attribute
<cflocation url="shop.cfm" statuscode="301" addtoken="false">
or I can use the cfheader tags.
<cfheader statuscode="301" statustext="Moved permanently">
<cfheader name="Location" value="http://www.mysite.com/shop.cfm">
Are there any reasons to use one method over the other?
I think they do the same thing, with <cflocation> being more readable
I tested this on ColdFusion 9.
There is one major difference, and it is that cflocation stops execution of the page and then redirects to the specified resource.
From the Adobe ColdFusion documentation:
Stops execution of the current page and opens a ColdFusion page or
HTML file.
So you would need to do this:
<cfheader statuscode="301" statustext="Moved permanently">
<cfheader name="Location" value="http://www.example.com/shop.cfm">
<cfabort>
to get the equivalent of this:
<cflocation url="shop.cfm" statuscode="301" addtoken="false">
Otherwise, you risk running into issues if other code runs after the cfheader tag. I came across this when fixing some code where redirects were inserted into an application.cfm file -- using cfheader -- without aborting the rest of the page processing.
I also noticed, in the response headers, that cflocation also sets the following headers accordingly:
Cache-Control: no-cache
Pragma: no-cache
One might want to add these headers in if using the cfheader tag with Location, if needed:
<cfheader name="Cache-Control" value="no-cache">
<cfheader name="Pragma" value="no-cache">
To elaborate on the Answer by Andy Tyrone, while they MAY do the same thing in certain circumstances, the CFHEADER method give you more control over the headers passed in the request. This becomes useful, for example, if you want to send cache control headers to a browser or content delivery network so that they do not keep hitting your server with the same old redirect request. There is no way (to my knowledge) to tell a CFLocation to cache the redirect.

Facebook Chat (XMPP) XEP 0080 support

I have being checking out using a prototype test program the capabilities of the XMPP Facebook Chat, X-FACEBOOK. It worked great using a geoloc message XEP 0080 with Gmail servers, but when i try to send the same XML structure through the X-FACEBOOK, it trims the message and removes the GeoLoc node.
I wanted to ask if someone knows if its possible to send XEP 0080 messages in X-FACEBOOK and if so what structure should I use so the Facebook Chat XMPP Server won't trim the GeoLoc info.
Sent XMPP geoloc message:
<message to="-100002578491827#chat.facebook.com" from="4yony4#chat.facebook.com/19256ca9_4C5CC12947646" type="chat" xml:lang="en">
<event xmlns="http://jabber.org/protocol/pubsub#event">
<items node="http://jabber.org/protocol/geoloc">
<item id="">
<geoloc xmlns="http://jabber.org/protocol/geoloc">
<lat>40.488137</lat>
<lon>-3.397623</lon>
<timestamp>2012-07-27 09:09:50 GMT</timestamp>
<msgType>0</msgType>
</geoloc>
</item>
</items>
</event>
<body>
</body>
Received message by client:
<message xmlns="jabber:client" from="-1177157556#chat.facebook.com" to="" type="chat">
<active xmlns="http://jabber.org/protocol/chatstates"/>
<body></body>
</message>
Any solution or opinion will be greatly appreciated.
Well, changed the XML to resemble the one you posted, without the pub sub, and still the same problem, the message received in the recipient lacks all the namespaces under the GeoLoc node, which I think is a result of the Server not supporting that format. I can try and use the IQ subscriber option, thing is that I prefer to find a solution on which I can directly send the info to a user.
If there is a possibility, even a small one in which i may be able to send information regarding GeoLoc from User A to User B in Facebook Server it may be of great help, if not well i guess i will have to accept it.
Thx for the help BTW.
When I was testing facebook XMPP connection, it did not support almost any extensions and blocked any custom tags on server. It was able to send basic presences, basic messages, vcards and that was about all it could do.
Pubsub events should be sent to services. Modern XMPP servers also support PEP extension and you can send pubsub to servers itself. In other cases, use message with target user as Robin have advised.
I do not think facebook has any server with pubsub. Also i think it still filters any unsupported namespaces. Feel free to prove me I am wrong, it is more than year since I last tested it.
These are not the same message.
The received message is simply an indicator of the users chat state, as defined in XEP-0085 and has no direct relationship to the message you sent. That doesn't mean that the first didn't potentially trigger the second, whatever library you are using may have sent the chatstate as well when you sent the message. This type of message is commonly used in chat clients to indicate that someone you are chatting with is typing a message.
The problem is probably that the message you are sending is in fact a PEP message. This is meant to be sent by the PEP service in the server, not from a client. I don't know if Facebook supports PEP or not, but I would guess that it is being filtered out due to your incorrect usage of a known namespace. PEP or Pubsub are the recommended ways of publishing geolocation information, but to utilize those you have to send an IQ packet to the service, not a message to the other client.
Try this instead (Not saying it will work, but at least the pubsub stuff is stripped):
<message to="-100002578491827#chat.facebook.com" from="4yony4#chat.facebook.com/19256ca9_4C5CC12947646" type="chat" xml:lang="en">
<geoloc xmlns="http://jabber.org/protocol/geoloc">
<lat>40.488137</lat>
<lon>-3.397623</lon>
<timestamp>2012-07-27 09:09:50 GMT</timestamp>
<msgType>0</msgType>
</geoloc>
<body>
</body>
</message>
I want to second Pihhan. It seems like the Facebook XMPP servers restructure messages to contain only the message body, date, and timestamp. I think they do that to keep it identical to their comment graph objects.
It is annoying, but I suspect it is deliberate. After all, their Graph is the main issue, not XMPP.