ODK collect can't GET forms from a rails API - ruby-on-rails

I have a custom rails application to store and aggregate forms from ODK Collect. I can submit a form but when I try getting a form from the server I get no forms yet there are forms.
When I test my API endpoint from curl everything is okay since I am rendering an xml with an array of forms and content-type: text/xml. Here is the output of
curl --head -X GET localhost:3000/formList
HTTP/1.1 200 OK
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Content-Type: text/xml; charset=utf-8
Etag: W/"950d3122ec123f00905885e0e57d8f1a"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: d2b51a32-2a72-4735-b60a-efd7e0419b93
X-Runtime: 0.012544
Server: WEBrick/1.3.1 (Ruby/2.2.1/2015-02-26)
Date: Tue, 01 Sep 2015 16:57:34 GMT
Content-Length: 380
Connection: Keep-Alive
curl -X GET localhost:3000/formList --- returns:
<?xml version="1.0" encoding="UTF-8"?>
<survey-xmls type="array">
<survey-xml>
<id type="integer">2</id>
<survey-xml>
<url>/uploads/survey_xml/survey_xml/2/CMS_1_.xml</url>
</survey-xml>
<created-at type="dateTime">2015-09-01T16:35:48+03:00</created-at>
<updated-at type="dateTime">2015-09-01T16:35:48+03:00</updated-at>
</survey-xml>
</survey-xmls>
Here is the server output when I run GET FORMS from ODK Collect.
Started GET "/formList" for ::1 at 2015-09-01 19:57:45 +0300
Processing by SurveyXmlsController#getforms as */*
SurveyXml Load (0.4ms) SELECT "survey_xmls".* FROM "survey_xmls"
Completed 200 OK in 3ms (Views: 2.3ms | ActiveRecord: 0.4ms)

Not sure if you ever figured it out but I recently had problems with getting a custom form list to pull into ODK Collect. The one piece of information I was missing was including the OpenRosa version in the response headers.
X-OpenRosa-Version: 1
Without this ODK Collect wouldn't pull in the list but it also wouldn't get an error, which made it difficult for me. This may be obvious solution to people familiar with OpenRosa but for me I was just starting to learn all this.

Related

Extremely slow PUT request in Redmine with plugins

I have the following tech stack:
Debian 8
Ruby 2.3
Nginx + Passenger
Redmine 3.3 issue tracker application
Agile plugin and Easy Gantt plugin for Redmine
Both Agile plugin and Easy Gantt plugin contain drag&drop visual UI, and dropping an item results in the PUT request. I don't know whether Redmine has any use of PUT requests anywhere apart from those plugins.
Problem is, these PUT requests are extremely slow for no obvious reason. They take ~120000 ms (120 sec, 2 minutes) to complete.
Here's log from log/production.log:
Started PUT "/agile/board" for 127.0.0.1 at 2016-10-23 20:08:03 +0300
Processing by AgileBoardsController#update as */*
Parameters: {"issue"=>{"status_id"=>"3"}, "positions"=>{"2"=>{"position"=>"0"}}, "id"=>"2"}
Current user: admin (id=1)
Rendered mailer/_issue.text.erb (4.8ms)
Rendered mailer/issue_edit.text.erb within layouts/mailer (8.2ms)
Rendered mailer/_issue.html.erb (1.3ms)
Rendered mailer/issue_edit.html.erb within layouts/mailer (4.3ms)
Rendered plugins/redmine_agile/app/views/agile_boards/_issue_card.html.erb (35.0ms)
Completed 200 OK in 120519ms (Views: 33.0ms | ActiveRecord: 41.0ms)
Here the date is at the moment of initiating the PUT request. So, what RoR did all these 2 minutes, if it rendered view in 33ms and worked with ActiveRecords in 41ms? What other activity could it perform which I can look at?
Here is the request headers from Firebug:
Host: redmine.local
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0
Accept: */*
Accept-Language: ru,ru-RU;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
X-CSRF-Token: ZKCHb1NeenfN6EVttTPHMiGItsTsKWDJPm5Q2VqaiYRRn420TH67pnwfRpWo/mQdDOWDhZNe1snDy+eP327PfQ==
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer: http://redmine.local/projects/myproject/agile/board
Content-Length: 60
Cookie: _redmine_session=MjI1Q <... lots of data ...>f
X-Compress: 1
Proxy-Authorization: c7f14568a48248797f198ea6e3c7d7c4f39185ce12aeac08439a9d6726a4cfd5612d4cef98c0ca43
Connection: keep-alive
Here is the answer from server:
Cache-Control: max-age=0, private, must-revalidate
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Sun, 23 Oct 2016 17:10:03 GMT
Etag: W/"0ec2e6c508ed9d99f224fc23e1fd3dbf"
Server: nginx/1.10.1 + Phusion Passenger 5.0.30
Set-Cookie: _redmine_session=VlZkakNTT <... lots of data ...>1f08a39ea5c63; path=/; HttpOnly
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Request-Id: 30b3a5f8-edb0-419a-b5f1-c6603439438a
X-Runtime: 120.523361
X-XSS-Protection: 1; mode=block
status: 200 OK
x-powered-by: Phusion Passenger 5.0.30
In the answer from server "Date" field shows 2 minutes from the moment of starting the PUT request, so I guess that server starts building this answer after those 2 minutes of... what?
In the timings panel of Firebug there's three zeroes for DNS resolving, connection and sending (I am connecting to my local server on the same machine), 120525ms waiting and 8ms receiving.
Here's the log record for this request from Nginx access.log:
127.0.0.1 - - [23/Oct/2016:20:10:03 +0300] "PUT /agile/board HTTP/1.1" 200 920 "http://redmine.local/projects/myproject/agile/board" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0"
I tried to replace Nginx+Passenger stack with Apache2+Passenger one, but problem persists. Even when I start the Webrick the 2 minutes timeout is there, so I believe it's either something with RoR, not the web server.
I have no prior experience writing the Ruby on Rails applications, only installing them.
Problem was that after_save was sending e-mails through sendmail and sendmail was stuck on the relatively well-known error "My unqualified host name (your hostname here) unknown; sleeping for retry". After I googled about this error and ensured that the correct FQN for my hostname was in the /etc/hosts, 2 minutes delay became 2 seconds delay.
127.0.0.1 localhost localhost.localdomain my-host-name

Error code: ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_LENGTH

I have a rails 2.3.8 application that worked just fine until I noticed that I'm not being able to download files from the same due to multiple Content-Length headers.
Interesting stuff is when I run the app on development mode everything works fine but when I restart the app on production mode I get this set twice.
Here are two different response headers:
When on production:
HTTP/1.1 200 OK
Date: Thu, 25 Jul 2013 07:33:42 GMT
Server: Mongrel 1.1.5
Status: 200 OK
X-Sendfile: filename.pdf
Content-length: 386742
Content-Transfer-Encoding: binary
Cache-Control: no-cache
Content-Disposition: attachment; filename="6301 OCCUPANT EMERGENCY PROCEDURES.pdf"
Content-Type: application/pdf
Content-Length: 1
Set-Cookie: *******
And on dev mode
HTTP/1.1 200 OK
Date: Thu, 25 Jul 2013 07:58:05 GMT
Server: Mongrel 1.1.5
Status: 200 OK
Content-Transfer-Encoding: binary
Cache-Control: private
Content-Disposition: attachment; filename="6301 OCCUPANT EMERGENCY PROCEDURES.pdf"
Content-Type: application/pdf
Content-Length: 386742
Set-Cookie: bssonline=f7d1552a46e499430af3367a0144267e; path=/
So on the dev mode only one Content-Length is found once whereas in the prod mode it comes twice due which Im not able to download any files.
Any idea as to how to solve this issue ?
Thanks

YouTube API setting playlist position

I'm using Version 2 of the YouTube API in PHP and have been so for over a year. Everything worked fine till around 2 weeks ago. I then noticed problems with the playlists, particularly adding video entries to playlists and setting the position.
My request headers and payload are correct, according to the API Documentation. I also receive a 200 Response Code and in the response body my playlist entry has a yt:position of 1. But checking the playlist the position is actually at the end, not the beginning.
I would like to know if anyone is having similar problems and if they perhaps have found a solution?
Below is a sample of my request / response:
Response:
HTTP/1.1 200 OK X-GData-User-Country: DE Content-Type: application/atom+xml; charset=UTF-8; type=entry GData-Version:
2.1 ETag: Transfer-Encoding: chunked Date: Thu, 13 Dec 2012 17:17:20 GMT Expires: Thu, 13 Dec 2012 17:17:20 GMT
Cache-Control: private, max-age=0 X-Content-Type-Options:
nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1;
mode=block Server: GSE Connection: close
<entry xmlns='http://www.w3.org/2005/Atom' xmlns:app='http://www.w3.org/2007/app'
xmlns:media='http://search.yahoo.com/mrss/'
xmlns:gd='http://schemas.google.com/g/2005'
xmlns:yt='http://gdata.youtube.com/schemas/2007' gd:etag=''>
...
<yt:position>
1
</yt:position> </entry>
Request:
PUT /feeds/api/playlists/PLAYLIST/PLAYLIST_ENTRY HTTP/1.1 Accept: / Host: gdata.youtube.com Connection: close
X-GData-Key: key=DEVELOPER_KEY User-Agent:
Zend_Framework_Gdata/1.11.8 authorization: GoogleLogin
auth=AUTH_KEY GData-Version: 2 Accept-encoding:
identity Content-Type: application/atom+xml Content-Length:
166
<?xml version="1.0" encoding="UTF-8"?><entry xmlns="http://www.w3.org/2005/Atom"
xmlns:yt="http://gdata.youtube.com/schemas/2007"><yt:position>1</yt:position></entry>

redmine: download wiki.html instead of the wiki page

as I don't manage to register in the forum in redmine.org, I am copying this question here with my actual problem.
I am running Redmine 2.1.4 on Ruby 1.8.7 and Rails 3.2.8 .
It is being served by an Apache 2.2.1 in a Debian Linux using Phusion Passenger 2.2.15
When I click on the Wiki of a project, I get a "download Wiki.html" behavior rather than the wiki page itself.
The downloaded Wiki.html has the content of the main Wiki page in a simple HTML format.
Here are my response headers with Content-Disposition clearly provoking this behaviour.
HTTP/1.1 200 OK
Date: Tue, 04 Dec 2012 01:17:33 GMT
Server: Apache/2.2
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 2.2.15
x-ua-compatible: IE=Edge,chrome=1
content-transfer-encoding: binary
X-Rack-Cache: miss
Content-Disposition: attachment; filename="Wiki.html"
Cache-Control: private
Status: 200
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 535
Keep-Alive: timeout=5, max=500
Connection: Keep-Alive
Content-Type: text/html
This is from the Redmine log:
Started GET "/projects/inventory/wiki.html" for 10.98.107.47 at Tue Dec 04 02:17:33 +0100 2012
Processing by WikiController#show as HTML
Parameters: {"project_id"=>"inventory"}
Current user: admin (id=4)
Rendered wiki/export.html.erb (1.7ms)
Rendered text template (0.0ms)
Sent data Wiki.html (0.4ms)
Completed 200 OK in 13ms (Views: 0.3ms | ActiveRecord: 3.2ms)
I was able to repair my installation by commenting out this line in redmine/public/.htaccess:
RewriteRule ^([^.]+)$ $1.html [QSA]
Is this directive an important part of Redmine? or Rails? I actually don't know who put all the configurations in .htaccess nor why.
Redmine seems to be working fine, but does anybody know if removing this directive will cause problems somewhere in Redmine?

D2L Dropbox - Posting issue

I'm getting an error trying to post a file to the dropbox in D2L. I'm using HttpRequest in PHP. The Org ID and Folder ID are both valid - I am retrieving the folder ID from the API (using the OrgID).
Here is the HttpRequest output:
POST /d2l/api/le/1.1/61381/dropbox/folders/677320/submissions/mysubmissions/?x_a=d0RNh1RjRGSMJu-dyj_wmw&x_b=_098IyP4bzkow_G-7Ke4Dv&x_c=3_L5VOX5RarK7mztTyX67sL_TyceBOK5r18GnRu9VbE&x_d=jVPR_DXuVf1JIl-YLe3Ad_OM2Ph8xG8UiMYriJVRc2w&x_t=1350769323 HTTP/1.1
User-Agent: PECL::HTTP/1.6.1-dev (PHP/5.2.6)
Host: <hostname>
Accept: */*
Content-Type: multipart/mixed; boundary=65ace1fa6e1f
Content-Length: 251
--65ace1fa6e1f
Content-type: application/json
{"Text":"test","HTML":null}
--65ace1fa6e1f
Content-Disposition: form-data; name=""; filename="file.txt"
Content-Type: application/octet-stream
eyAiVGVztCI6IlRsaXMgfXMgdGVzdYBkYXRhLiIgfQ==
--65ace1fa6e1f--
And the response:
HTTP/1.1 302 Found
Cache-Control: private
Content-Length: 131
Content-Type: text/html; charset=utf-8
Location: /d2l/error/404
Server: Microsoft-IIS/6.0
X-XSS-Protection: 0
X-Powered-By: ASP.NET
Date: Sat, 20 Oct 2012 21:42:26 GMT
It appears to be a 404 (No such dropbox folder, or no such org unit), but I know both values to be valid.
I've logged into D2L and the OrgID and DropboxID are both correct in the URL when I'm editing the dropbox settings. The user in question has permission to access the dropbox, and can do so in D2L.
Any help would be appreciated!

Resources