Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all 4845 articles
Browse latest View live

New Post: Creating JSON arrays

$
0
0
I looked at the JSON page provided, but I am still not sure how you create a JSON object and send it back, more spefically a JSON array, such as
[
    { "Title": "DSU" },
    { "Title": "USD" }
]
I suppose I could do something like this using a format string (as DSU, USD would be dynamic data)
json::value seasons = json::value::parse(U("[{\"Title\": \"DSU\"},{\"Title\": \"USD\"}]"));
however I much rather do something like
json::value seasons = json::value::array();

for(int i = <0; i < data.count; i++)
{
     seasons[i]["Title"] = json::foo(data[i]);
}
Could anyone provide a basic example? Thanks

New Post: Creating JSON arrays

$
0
0
hey ntgates

Yes, we completely support what you are looking for :)
You can use json::value::string() to construct a json string and assign it as json object values, something like:
    json::value seasons = json::value::array();
    for (int i = 0; i < data.size(); i++)
    {
        seasons[i][U("Title")] = json::value::string(data[i]);
    }
I would browse through our tests to get a better understanding of how to use the JSON APIs, for instance: JSON construction test has examples on how to construct JSON arrays, objects, strings. (Please note, we are moving to github, hence the reference from github).

Thanks
Kavya.

New Post: How to set http_requset body in an HTTP POST with content type "multipart/form-data"

$
0
0
How can one post multiple files/parts in a single request? Like if I want to post a request with has two parts, 1st a JSON string and second a binary file.
--Boundary
Content-Disposition: form-data; name="myJsonString"
Content-Type: application/json

{"foo": "bar"}
--Boundary
Content-Disposition: form-data; name="photo"
Content-Type: image/jpeg

<file binary here..>
--Boundary--
Also, is there any way I can do this without reading the binary file into a string?

Thanks.

New Post: Unable to build on Mac OS X

$
0
0
Hi,
I am trying to build following the instructions here. The only change I have made is that I use macports instead of homebrew to install the dependencies.

While running cmake on the project, I see this warning
  MACOSX_RPATH is not specified for the following targets:

   common_utilities
   cpprest
   httpclient_test
   httplistener_test
   httptest_utilities
   json_test
   pplx_test
   streams_test
   unittestpp
   uri_test
   utils_test
   websocketclient_test
   websockettest_utilities

This warning is for project developers.  Use -Wno-dev to suppress it.

When building the project (at target cpprest), I end up with a bunch of
cpprestsdk/Release/include/cpprest/details/basic_types.h:42
 unused typedef '__C_ASSERT__' [-Werror,-Wunused-local-typedef]
        C_ASSERT( IntTraits<U>::isUint64 );

expanded from macro 'C_ASSERT'
#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]

fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
The build aborts at this point. I am doing the build on OSX Yosemite 10.10.5 with XCode 7.0.1 installed. Clang version is Apple LLVM version 7.0.0 (clang-700.0.72). I would appreciate some pointers/assistance in getting cpprestsdk to build on this platform. Thanks

P.S. The source I am using is from the github repo.

New Post: Unable to build on Mac OS X

$
0
0
Hi,
I've gotten it to build after adding the following lines to Release/CMakeLists.txt under the clang section of the cmake file
add_definitions("-Wno-error=unused-local-typedefs")
add_definitions("-Wnounused-local-typedefs")
Googling led me to a simlar issue on a different project on github - https://github.com/OpenImageIO/oiio/issues/1089

Some of the test (like the outside_cnn_dot_com) fails. But, looking at it, the test seems to be expecting code 200 for cnn.com, but, it actually does give a 302 (which seems to be what the test is expecting).

Hope this helps anyone else who runs into this issue. If there is a better way to fix it, I would love to learn it. Thanks

George

New Post: Is cpprest.natvis broken?

$
0
0
I am trying to use cpprest.natvis in VS2015 to look at the value in web::json::value variable, but I'm getting this error:
Natvis: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Packages\Debugger\Visualizers\cpprest.natvis(168,68): Error: a pointer to a bound function may only be used to call the function
    Error while evaluating '(*((web::json::details::_Number*)((m_value)._Myptr))).m_number' in the context of type 'XXX.dll!web::json::value'.
The error is about checking the m_kind:
<Type Name="web::json::value">
    <DisplayString Condition="(m_kind==web::json::value::Number)">
      {(*((web::json::details::_Number*)((m_value)._Myptr))).m_number}
    </DisplayString>
It looks like web::json::value::Number is correct description of an element of web::json::value_type enum, so, what's the problem here?

Are all you guys in Casablanca team working in Linux and nobody is using VS2015? It's not that bad, check it out! :-)

New Post: NuGet package for Visual Studio 2015 not works

$
0
0
Is there any news about the 2.7.0 release?

New Post: OAuth Client


New Post: C++ REST SDK packages

$
0
0
Hi
After downloading cpprestsdk in VS 2013, i found 7 folders (cpprestsdk.v120.winphone... cpprestsdk.v120.winpp... ) in the project folder, it weighs around 1,5 Gb. Actually, I'm not using all these features and I want to remove it.
Can I do it? If yes, how?

New Post: NuGet package for Visual Studio 2015 not works

$
0
0
Hey atono

We are still working on it. We are in the process of moving to github and we should be able to put the release together next week.

Thanks
Kavya

New Post: C++ REST SDK packages

$
0
0
Yes, it should be possible.
Which features are you interested in particular?
Another option is to build the product from sources.

I can give a solution that suits you best based on the features you are interested in. Let me know.

Thanks
Kavya.

New Post: Is cpprest.natvis broken?

New Post: C++ REST SDK packages

$
0
0
I have these packages in the project folder:
cpprestsdk.v120.winapp
cpprestsdk.v120.windesktop
cpprestsdk.v120.winphone
cpprestsdk.v120.winphonesl
cpprestsdk.v120.winxp
cpprestsdk.v140.winapp
cpprestsdk.v140.windesktop

I'm not interested in winphone and winphonesl . How to remove it properly from my project? Also, i need only x64 support.

Thanks.

New Post: Does Casablanca have an internal bandwidth limit?

$
0
0
I've been writing a Windows console application using Casablanca, but I've been having performance issues on transfer rate. Metrics show that the console application is transferring a byte stream at roughly 6-8 Mbytes/sec.

To diagnose this, we looked at the application's file read speeds. It was getting anywhere from 20 Mbytes/sec to 100 Mbytes/sec. The variation depends on the size of the request. Read lots of small chunks, and throughput goes down. On average, file reads were at 80 Mbytes/sec.

We then tested Casablanca for local host to local host transfer with large file reads (to eliminate the variation.) We got transfer rates of about 60 Mbytes/sec. But when we tested the application between a virtual machine on the network and a physical machine, the transfer rate was at 6-8 Mbytes/sec.

Since the drop in performance occurred going from local host loop to real network, we then used curl to test a 1Gig download on the actual network. We got transfer rates of around 60 Mbytes/sec.

Here's what we think is happening:
  • Disk read isn't the bottleneck. Speed here is around 80 Mb/s or higher.
  • Local loop isn't the bottleneck. Speed here is around 60 Mb/s or higher.
  • Network isn't the bottleneck. Speed here between IIS and curl is around 60 Mb/s or higher.
  • Casablanca seems to be the bottleneck. Speed here goes from 80 Mb/s to 8 Mb/s.
We looked at the network load monitor: Between IIS and curl, the transfer had a ramp up, a flat plateau, and then a ramp down. As expected. Between Casablanca and curl, it was jagged spikes all the way, and it never really reach the higher transfer rates.

As first I thought, maybe I was using the streaming wrongly. The console application uses a producer-consumer buffer and ties an iStream and oStream to it. We do a write to it after a disk read. Debug logged output shows that the application quickly fills the REST buffer and is done with the disk read. The rest of the time is spent by Casablanca pushing out the buffer to network.

But when we tested with a code change (changed the code to not stream, but to read in the entire request into memory and then send it all at once in the reply body,) the change was negligible. Network monitoring showed Casablanca still dumped the 1Gig file in little bursts, constant spikes.

I'm wondering what we're doing wrong here. Can anyone offer any insight?

New Post: Does Casablanca have an internal bandwidth limit?

$
0
0
A colleague of mine did some digging around in the C++ REST code, and he discovered that there is a hard-coded chunk size value.

In http_server_httpsys.cpp
#define CHUNK_SIZE 64 * 1024

When we increased the chunk size from 64Kbytes to 5Mbytes, it improved the performance dramatically. By dramatically, Casablanca's transfer speeds went from 8 Mbyte/s to 42 Mbyte/s. Of course, this now means we have to maintain a separate version of Casablanca for our purposes.

In lieu of this, I have some further questions:
  1. Are there any hidden consequences for messing around with this CHUNK_SIZE value?
  2. Are there any plans to expose CHUNK_SIZE to developers so we can tune Casablanca's performance without having to modify the API source?
By the way, Casablanca is an amazing project. Aside from this performance hiccup, it has been a joy to code with. Thumbs up to the development team.

New Post: Build for OSX

$
0
0
When i completed build for OSX, i copied libcpprest.2.6.dylib to another Mac OSX machine to run my app, Xcode show error can not find boost path that is referenced in the library libcpprest.

Can i use boost & openssl with the dynamic library when build libcpprest for osx ?

Help me!

New Post: Cannot open include file error when using cpprestsdk in VS2015 with NuGet

$
0
0
I created a new project using VS2015 Pro using Universal Windows application template. After I added cpprestsdk using NuGet Management UI for the project, I found that I could not compile the project. The VC++2015 complained that <cpprest/json.h> could not be found!
The same happened to another project which was created using VC2013. The project compiled fine until I migrated it to UWP.
I've also tried creating Windows 8.1 project using VC2015 with cpprestsdk, but got the same compilation error.
I thought NuGet manage the include path automatically, right?
Did I miss anything?

New Post: C++ REST SDK packages

$
0
0
You can uninstall the packages that you are not using from NuGet management UI. Just use "installed" filter to reveal the projects that have installed the package, and use "uninstall" command to uninstall the package from the selected projects.

New Post: Upload in chunks with a transformation

$
0
0
Hi,

I'm working on an application that needs to upload very large files to a webserver, and apply a specific transformation (end to end encryption) to the data before it is sent to the server. Because the files are very large, I want to avoid:

1) Reading the whole file into memory before encrypting.
2) Writing a temporary file that is encrypted to disk and uploading that.

What I really want to do is read the file from disk in chunks, apply the transformation and then upload the transformed chunk, and then move on to the next chunk.

I've investigated a number of different ways of doing this. (producer consumer, subclassing streambuf, custom pipeline stage). What is the recommended approach? Any details would be very welcome.

Thanks,
Chris

New Post: C++ REST SDK packages

$
0
0
cpprestsdk nuget package includes the entire bundle (cpprest library for VS2013, VS2014, Phone, Desktop, Windows Store App development).

You can also selectively install only the packages that you are planning to reference. For instance, if you are using VS2013, you can choose to install the corresponding packages:
cpprestsdk.v120.winapp.*
cpprestsdk.v120.windesktop.*
And ignore the rest.

Hope this helps.

Thanks
Kavya
Viewing all 4845 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>